-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
74 lines (71 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
const gulp = require("gulp");
gulp.task("copy-html",function(){
return gulp.src("*.html")
.pipe(gulp.dest("dist/"))
.pipe(connect.reload());
})
gulp.task("copy-php",function(){
return gulp.src("php/*.php")
.pipe(gulp.dest("dist/php"))
.pipe(connect.reload());
})
gulp.task("images",function(){
return gulp.src("images/**/*")
.pipe(gulp.dest("dist/images"))
.pipe(connect.reload());
})
gulp.task("data",function(){
return gulp.src(["data/*.json","data/*.xml"])
.pipe(gulp.dest("dist/data"))
.pipe(connect.reload());
})
gulp.task("css",function(){
return gulp.src(["*.css"])
.pipe(gulp.dest("dist/css"))
.pipe(connect.reload());
})
gulp.task("scripts", function(){
return gulp.src(["*.js", "!gulpfile.js"])
.pipe(gulp.dest("dist/js"))
.pipe(connect.reload());
})
gulp.task("scripts2",function(){
return gulp.src("js/*.js")
.pipe(gulp.dest("dist/js"))
.pipe(connect.reload());
})
gulp.task("iconfont",function(){
return gulp.src("Iconfont/*")
.pipe(gulp.dest("dist/iconfont"))
.pipe(connect.reload());
})
const sass = require("gulp-sass");
gulp.task("sass",function(){
return gulp.src("scss/*.scss")
.pipe(sass())
.pipe(gulp.dest("dist/css"))
.pipe(connect.reload());
})
//监听
gulp.task("watch",function(){
gulp.watch("*.html",["copy-html"]);
gulp.watch("php/*.php",["copy-php"]);
gulp.watch("img/**/*",["images"]);
gulp.watch(["data/*.json","data/*.xml"],["data"]);
gulp.watch("scss/*.scss",["sass"]);
gulp.watch(["*.js", "!gulpfile.js"],["scripts"]);
gulp.watch("js/*.js",["scripts2"]);
gulp.watch("Iconfont/*",["iconfont"]);
})
gulp.task("build",["copy-html","copy-php","images","data","scripts","scripts2","sass","css","iconfont"],function(){
console.log("执行成功");
})
const connect = require("gulp-connect");
gulp.task("server",function(){
connect.server({
root:"dist",//设置根目录
port: 8887,//设置端口号
livereload: true //启动实时刷新功能
})
})
gulp.task("default",["watch","server"]);