forked from saveweb/SSLCheck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
98 lines (86 loc) · 2.05 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
let gulp = require('gulp');
let autoprefixer = require('gulp-autoprefixer');
let cleanCSS = require('gulp-clean-css');
let uglify = require('gulp-uglify');
let rename = require("gulp-rename");
let htmlmin = require("gulp-htmlmin");
let htmlclean = require("gulp-htmlclean");
let del = require('del');
var configs = {
autoprefixer: {
browsers: [
'last 2 versions',
'> 1%',
'Chrome >= 40',
'Firefox >= 40',
'ie >= 10',
'Safari >= 8',
],
},
cleanCSS: {
compatibility: 'ie10'
},
};
function minifyJS() {
return gulp.src('src/**/*.js')
.pipe(uglify({
output: {
comments: /^!/
}
}))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('dist'));
}
function minifyCSS() {
return gulp.src('src/**/*.css')
.pipe(autoprefixer(configs.autoprefixer))
.pipe(cleanCSS(configs.cleanCSS))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('dist'));
}
function minifyHTML() {
return gulp.src('src/**/*.html')
.pipe(htmlmin({
removeComments: true,
minifyJS: true,
minifyCSS: true,
collapseWhitespace: true,
}))
.pipe(htmlclean())
.pipe(gulp.dest('dist'))
}
function copyDist() {
return gulp.src('dist/**/*')
.pipe(gulp.dest('public'))
}
function copyAssets() {
return gulp.src('src/**/*')
.pipe(gulp.dest('public'))
}
function clean() {
return del([
'public/**/*'
]);
}
exports.clean = clean;
exports.minifyJS = minifyJS;
exports.minifyCSS = minifyCSS;
exports.minifyHTML = minifyHTML;
exports.copyDist = copyDist;
exports.copyAssets = copyAssets;
gulp.task('build', gulp.series(
clean,
gulp.parallel(
minifyJS,
minifyCSS,
minifyHTML
),
gulp.series(
copyAssets,
copyDist
)
));
gulp.task('default', gulp.series('build'));
gulp.task('watch', function () {
gulp.watch('src/**', gulp.series('build'));
});