-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
32 lines (26 loc) · 857 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
const gulp = require('gulp');
const gulpPreprocess = require('gulp-preprocess');
const gulpTerser = require('gulp-terser');
const gulpClone = require('gulp-clone');
const gulpRename = require('gulp-rename');
const gulpReplace = require('gulp-replace');
const PATH_SRC = './src';
const PATH_DIST = './lib';
const SRC_GLOB_MODULES = `${PATH_SRC}/modules/*.js`;
const SRC_GLOB_ALL = `${PATH_SRC}/**/*.js`;
gulp.task('build', () => {
const clone = gulpClone.sink();
return gulp
.src(SRC_GLOB_MODULES)
.pipe(gulpPreprocess())
.pipe(clone)
.pipe(gulpTerser({ecma: 8}))
.pipe(gulpReplace('()=>', 'Q=>'))
.pipe(gulpRename({suffix: '.min'}))
.pipe(clone.tap())
.pipe(gulp.dest(`${PATH_DIST}`));
});
gulp.task('watch', () => {
return gulp.watch(SRC_GLOB_ALL, gulp.series(['build']));
});
gulp.task('default', gulp.series(['build', 'watch']));