-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
40 lines (36 loc) · 1.32 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
const gulp = require('gulp');
const compilerPackage = require('google-closure-compiler');
const closureCompiler = compilerPackage.gulp();
compilerPackage.compiler.JAR_PATH = undefined;
compilerPackage.compiler.prototype.javaPath = './node_modules/.bin/closure-gun';
const rename = require("gulp-rename");
const gzip = require('gulp-gzip');
gulp.task('minify', done => {
closureCompiler({
js: './dist/canvas.js',
compilation_level: 'SIMPLE',
language_in: 'ECMASCRIPT6_STRICT',
language_out: 'ECMASCRIPT5_STRICT',
js_output_file: 'canvas.min.js'
}).src()
.pipe(gulp.dest('./dist/'));
closureCompiler({
js: './dist/unitary.js',
compilation_level: 'SIMPLE',
language_in: 'ECMASCRIPT6_STRICT',
language_out: 'ECMASCRIPT5_STRICT',
js_output_file: 'unitary.min.js'
}).src()
.pipe(gulp.dest('./dist/'))
.pipe(gzip()).pipe(gulp.dest('./dist/'))
.on('end', () => {
const files = ['unitary.browser.js', 'unitary.browser.min.js', 'unitary.browser.min.js.gz'];
for (const file of files) {
gulp.src('./dist/' + file.replace('.browser', ''))
.pipe(rename(file))
.pipe(gulp.dest('./dist'));
}
done();
});
});
gulp.task('default', gulp.series(gulp.parallel(['minify'])));