forked from ChrAlpha/theme-cards-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
67 lines (60 loc) · 1.47 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
var gulp = require('gulp');
var autoPrefixer = require('gulp-autoprefixer');
var cleanCSS = require('gulp-clean-css');
var uglifyJS = require('gulp-uglify-es').default;
var htmlMin = require('gulp-htmlmin');
var htmlClean = require('gulp-htmlclean');
var configs = {
autoPrefixer: {
overrideBrowserslist: [
'last 2 versions',
'> 1%',
'Chrome >= 40',
'Firefox >= 40',
'ie >= 10',
'Safari >= 8'
]
},
uglifyJS: {
toplevel: true
},
cleanCSS: {
compatibility: 'ie10'
},
htmlMin: {
removeComments: true,
minifyJS: true,
minifyCSS: true,
collapseWhitespace: true
}
};
function minifyJS() {
return gulp.src('./public/**/*.js')
.pipe(uglifyJS(configs.uglifyJS))
.pipe(gulp.dest('./public'));
}
function minifyCSS() {
return gulp.src('./public/**/*.css')
.pipe(autoPrefixer(configs.autoPrefixer))
.pipe(cleanCSS(configs.cleanCSS))
.pipe(gulp.dest('./public'));
}
function minifyHTML() {
return gulp.src('./public/**/*.html')
.pipe(htmlMin(configs.htmlMin))
.pipe(htmlClean())
.pipe(gulp.dest('./public'));
}
module.exports = {
minifyJS: minifyJS,
minifyCSS: minifyCSS,
minifyHTML: minifyHTML
};
gulp.task('build', gulp.series(
gulp.parallel(
minifyJS,
minifyCSS,
minifyHTML
)
));
gulp.task('default', gulp.series('build'));