-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
134 lines (116 loc) · 3.72 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
const gulp = require('gulp')
const minify = require('gulp-minify')
const concat = require('gulp-concat')
const changed = require('gulp-changed')
const cleancss = require('gulp-clean-css')
const jsdoc = require("gulp-jsdoc3")
const jshint = require("gulp-jshint")
const rimraf = require('rimraf')
const LIBDIR = 'lib'
const LIBJS = LIBDIR+"/js"
const LIBCSS = LIBDIR+"/css"
const LIBIMG = LIBDIR+"/images"
const DOCDIR = './docs'
async function clean() {
await Promise.all([
rimraf(LIBJS),
rimraf(LIBCSS),
rimraf(LIBIMG)
])
}
gulp.task('clean',
function(cb) {
clean().then(cb);
});
function clean_css() {
return gulp.src(['src/jsbrain.css','src/newdesign.css',
'src/editorpage.css','src/pikaday.css'])
.pipe(changed(LIBCSS))
.pipe(cleancss())
.pipe(gulp.dest(LIBCSS))
}
function compress_js() {
return gulp.src(['src/polyfit.js','src/pikaday.js',
'src/butil.js','src/broad.js','src/beebrain.js',
'src/bgraph.js',
'src/bsandbox.js',
'src/btest.js',
'src/client.js',
'src/newdesign.js'])
.pipe(changed(LIBJS))
.pipe(minify({ext:{src:".js", min:".min.js"}, noSource:true}))
.pipe(gulp.dest(LIBJS))
}
function combine_bbrjs() {
return gulp.src(['src/butil.js','src/broad.js','src/beebrain.js'])
.pipe(concat('bbrpack.js'))
.pipe(gulp.dest(LIBJS))
}
function combine_bgrjs() {
return gulp.src(['src/polyfit.js','src/pikaday.js',
'src/butil.js','src/broad.js','src/beebrain.js',
'src/bgraph.js'])
.pipe(concat('bgrpack.js'))
.pipe(gulp.dest(LIBJS))
}
function combine_bsbjs() {
return gulp.src(['src/polyfit.js','src/pikaday.js',
'src/butil.js','src/broad.js','src/beebrain.js',
'src/bgraph.js','src/bsandbox.js'])
.pipe(concat('bsbpack.js'))
.pipe(gulp.dest(LIBJS))
}
function combine_js(cb) {
let a = gulp.series(combine_bbrjs, combine_bgrjs, combine_bsbjs)
return a(cb)
}
function combine_bbrjsmin() {
return gulp.src(['lib/js/butil.min.js','lib/js/broad.min.js',
'lib/js/beebrain.min.js'])
.pipe(concat('bbrpack.min.js'))
.pipe(gulp.dest(LIBJS))
}
function combine_bgrjsmin() {
return gulp.src(['lib/js/polyfit.min.js','lib/js/pikaday.min.js',
'lib/js/butil.min.js','lib/js/broad.min.js',
'lib/js/beebrain.min.js', 'lib/js/bgraph.min.js'])
.pipe(concat('bgrpack.min.js'))
.pipe(gulp.dest(LIBJS))
}
function combine_bsbjsmin() {
return gulp.src(['lib/js/polyfit.min.js','lib/js/pikaday.min.js',
'lib/js/butil.min.js','lib/js/broad.min.js',
'lib/js/beebrain.min.js', 'lib/js/bgraph.min.js',
'lib/js/bsandbox.min.js'])
.pipe(concat('bsbpack.min.js'))
.pipe(gulp.dest(LIBJS))
}
function combine_jsmin(cb) {
let a = gulp.series(combine_bbrjsmin, combine_bgrjsmin, combine_bsbjsmin)
return a(cb)
}
function copy_vendor() {
return gulp.src(['src/moment.min.js', 'src/moment-timezone.min.js'])
.pipe(gulp.dest(LIBJS))
}
function gendoc() {
var config = require('./jsdoc.json')
return gulp.src(['README.md', 'src/*.js'], {read: false})
.pipe(jsdoc(config));
}
function linter() {
return gulp.src(['src/butil.js', 'src/broad.js', 'src/bgraph.js', 'src/bsandbox.js', 'src/newdesign.js']).pipe(jshint({esversion:8, asi:true, laxbreak:true})).pipe(jshint.reporter('default'))
}
function images() {
return gulp.src('src/images/*')
.pipe(gulp.dest(LIBIMG))
}
exports.compile = gulp.series(clean,
images,
compress_js,
gulp.parallel(combine_js,
combine_jsmin,
clean_css),
copy_vendor)
exports.gendoc = gendoc
exports.jshint = linter