-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
34 lines (29 loc) · 948 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
const fs = require('fs');
const path = require('path');
const gulp = require('gulp');
const del = require('del');
const closureCompiler = require('google-closure-compiler').gulp();
gulp.task('backup', () => {
return gulp.src(['public/**/*.js', '!public/**/*.min.js'], {base: './'})
.pipe(gulp.dest('src'));
});
gulp.task('build', () => {
return gulp.src('src/public/**/*.js', {base: './'})
.pipe(closureCompiler({
compilation_level: 'SIMPLE',
language_out: 'ECMASCRIPT5_STRICT',
output_wrapper: '(function(){\n%output%\n}).call(this)',
js_output_file: 'bundle.min.js',
}))
.pipe(gulp.dest('public/js'));
});
gulp.task('production', (cb) => {
fs.writeFile(path.join(__dirname, '.env'), 'NODE_ENV = production', cb);
});
gulp.task('clean', () => {
return del([
'public/**/*.js',
'!public/**/*.min.js',
]);
});
gulp.task('default', gulp.series('backup', 'build', 'clean', 'production'));