-
Notifications
You must be signed in to change notification settings - Fork 205
Expand file tree
/
Copy pathgulpfile.js
More file actions
executable file
·54 lines (48 loc) · 1.19 KB
/
gulpfile.js
File metadata and controls
executable file
·54 lines (48 loc) · 1.19 KB
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 { series, src, dest, watch } = require("gulp");
const browserSync = require("browser-sync").create();
var minifycss = require("gulp-minify-css");
var uglify = require("gulp-uglify");
var htmlmin = require("gulp-htmlmin");
// 代理
function browserSyncTask(cb) {
browserSync.init({
reloadDebounce: 500, // 单位:毫秒
proxy: "http://0.0.0.0:4000/",
files: ["source/**/**.md", "public/**/*"],
});
cb();
}
// 压缩css
function minifycss(cb) {
return src("public/**/*.css")
.pipe(
minifycss().on("error", function (e) {
console.log(e);
})
)
.pipe(dest("public"));
cb();
}
// 压缩html
function minifyhtml(cb) {
var option = {
removeComments: true,
minifyJS: true,
minifyCSS: true,
collapseWhitespace: true,
};
return src("public/**/*.html").pipe(htmlmin(option)).pipe(dest("public"));
cb();
}
// 压缩js
function minifyjs() {
return src("public/js/**/*.js")
.pipe(
uglify().on("error", function (e) {
console.log(e);
})
)
.pipe(dest("public/js"));
}
exports.default = browserSyncTask;
exports.min = series(minifyhtml, minifycss, minifyjs);