-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
49 lines (43 loc) · 1.35 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
/**
* Created by mike on 2017/7/6.
*/
var gulp=require("gulp");
var plugins = require('gulp-load-plugins')();
gulp.task("default",function () {
plugins.livereload.listen();
gulp.watch("public/css/front/*.less",["cssMin"]);
gulp.watch(["public/scripts/front/*[^(min)].js","public/scripts/admin/*[^(min)].js"],["jsMin"]);
gulp.watch("views/**/*.html",function (event) {
plugins.livereload.changed(event.path);
});
});
/* 编译 、压缩 css */
gulp.task("cssMin",function () {
gulp.src("public/css/front/*.less")
.pipe(plugins.less())
.pipe(gulp.dest("public/css/front/"))
.pipe(plugins.minifyCss())
.pipe(plugins.rename({
extname: ".min.css"
}))
.pipe(gulp.dest("public/css/front/"))
.pipe(plugins.livereload());
});
/* 压缩 js */
gulp.task("jsMin",function () {
//压缩js文件
gulp.src("public/scripts/admin/!(*.min).js")
.pipe(plugins.uglify())
.pipe(plugins.rename({
extname: ".min.js"
}))
.pipe(gulp.dest("public/scripts/admin/"))
.pipe(plugins.livereload());
gulp.src("public/scripts/front/!(*.min).js")
.pipe(plugins.uglify())
.pipe(plugins.rename({
extname: ".min.js"
}))
.pipe(gulp.dest("public/scripts/front/"))
.pipe(plugins.livereload());
});