-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·54 lines (49 loc) · 1.42 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
const gulp = require('gulp');
const babel = require('gulp-babel');
const uglify = require('gulp-uglify');
const htmlmin = require("gulp-htmlmin");
const htmlclean = require("gulp-htmlclean");
let minifyHTML = () => {
return gulp.src('src/**/*.html')
.pipe(htmlmin({
removeComments: true,
collapseWhitespace: true,
collapseBooleanAttributes: true,
removeEmptyAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
minifyJS: true,
minifyCSS: true
}))
.pipe(htmlclean())
.pipe(gulp.dest('dist'));
}
let minifyJS = () => {
return gulp.src('src/**/*.js')
.pipe(babel({
"presets": [
["@babel/env", {
"targets": [
'last 2 versions',
'since 2015',
'> 1%',
'Chrome >= 30',
'Firefox >= 30',
'ie >= 9',
'Safari >= 9',
]
}]
]
}))
.pipe(uglify({
keep_fnames: false
}))
.pipe(gulp.dest('dist'));
}
exports.minifyHTML = minifyHTML;
exports.minifyJS = minifyJS;
gulp.task('build', gulp.parallel(
minifyHTML,
minifyJS
));
gulp.task('default', gulp.parallel('build'));