-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
68 lines (61 loc) · 1.71 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
const { series, parallel, src, dest } = require('gulp');
const del = require('del');
const uglify = require('gulp-uglify-es').default;
const htmlmin = require('gulp-htmlmin');
const cssmin = require('gulp-clean-css');
const zip = require('gulp-zip');
const include = require('gulp-include');
const paths = {
root: '.',
src: {
base: 'dev',
html: `dev/**/*.html`,
css: `dev/**/*.css`,
js: `dev/**/*.js`,
lib: `dev/lib/**/*`
},
dist: {
base: 'public',
dir: `public`,
all: `public/**/*`
},
zip: `public.zip`
};
const jsOptions = {
mangle: {
toplevel: true, // mangles top level names
reserved: ['kontra'] // don't mangle var=kontra, expected in client.js
},
nameCache: {}, // prevents mangled-name conflicts across files
};
const htmlOptions = { collapseWhitespace: true }
function cleanTask() {
return del([paths.dist.dir, paths.zip]);
}
function buildJsTask() {
return src(paths.src.js, { ignore: paths.src.lib })
.pipe(include()) // inserts lib files into server.js
/* Uglification makes debugging hard during dev. TODO: restore closer to production */
.pipe(uglify(jsOptions))
.pipe(dest(paths.dist.dir));
}
function buildHtmlTask() {
return src(paths.src.html)
.pipe(htmlmin(htmlOptions))
.pipe(dest(paths.dist.dir));
}
function buildCssTask() {
return src(paths.src.css)
.pipe(cssmin())
.pipe(dest(paths.dist.dir));
}
function zipTask() {
return src(paths.dist.all)
.pipe(zip(paths.zip))
.pipe(dest(paths.root))
}
exports.build = series(
cleanTask,
parallel(buildJsTask, buildHtmlTask, buildCssTask),
zipTask
);