-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
42 lines (35 loc) · 1001 Bytes
/
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
/** K.Arthur 4/10/2019 */
const { src, dest, series } = require('gulp');
const rollup = require('rollup');
const uglify = require('gulp-uglify');
const rename = require('gulp-rename');
const babel = require('gulp-babel');
const _delete = require('delete');
const rollupConfig = require('./rollup.config');
const buildConfig = require('./package').buildConfig;
async function bundle() {
const bundle = await rollup.rollup({
input: rollupConfig.input,
plugins: rollupConfig.plugins
});
return bundle.write(rollupConfig.output);
}
function build() {
return src(buildConfig.middle)
.pipe(babel())
.pipe(rename({ extname: '.js' }))
.pipe(dest(buildConfig.output))
.pipe(uglify())
.pipe(rename({ extname: '.min.js' }))
.pipe(dest(buildConfig.output));
}
const clean = {
all(cb) {
_delete([buildConfig.output], cb);
},
temp(cb) {
_delete([buildConfig.middle], cb);
}
};
// exports
exports.default = series(clean.all, bundle, build, clean.temp);