-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
74 lines (63 loc) · 1.67 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
const { src, dest, series, task } = require('gulp');
const del = require('del');
const eslint = require('gulp-eslint');
const uglify = require('gulp-uglify');
const size = require('gulp-size');
const header = require('gulp-header');
const pkg = require('./package.json');
const _src = './src/*.js'; // pkg.module;
const _dest = './build'; // pkg.main;
const _dest_src = _dest + '/*.js';
var banner = ['/** <%= pkg.name %> v<%= pkg.version %> */',
// '/**',
// ' * <%= pkg.name %> v<%= pkg.version %>',
// ' * <%= pkg.repository %>',
// ' * @license <%= pkg.license %>',
// ' */',
''].join('\n');
const MINIFY_JS_OPTIONS = {
//output: {compress:true},
compress: {
passes: 3,
// drop_console: true, // false = SHOW CONSOLE LOG
pure_funcs: ['console.debug', console.log],
dead_code: true,
drop_debugger: true,
join_vars: true,
collapse_vars: true
},
mangle: {
reserved: ['console.debug', console.log],
},
ie8: false,
};
// Clean Output Directory
function clean(cb) {
del.sync([_dest]);
cb();
};
function copy() {
return src(_src)
.pipe(dest(_dest))
.pipe(size({title: "SOURCE"}));
}
function lint() {
return src(_src)
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
}
function compress() {
return src(_dest_src)
.pipe(uglify(MINIFY_JS_OPTIONS))
.pipe(dest(_dest))
.pipe(size({ title: "BUILD" }));
}
function addBanner() {
return src(_dest_src)
.pipe(header(banner, { pkg: pkg }))
.pipe(dest(_dest))
.pipe(size({ title: "BUILD WITH BANNER" }));
}
exports.default = series(lint);
exports.build = series(lint, clean, copy, compress, addBanner);