-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
94 lines (75 loc) · 1.8 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
var gulp = require("gulp");
var bowserSync = require("browser-sync");
var reload=bowserSync.reload;
var nodemon = require('gulp-nodemon');
var path = require("path");
var cmd=require("node-cmd");
var del=require("del");
var webpackConfig = require(path.join(__dirname, "admin/webpack.config"));
var appIndex = path.join(__dirname, "public/admin/src/index.js");
var webpackBulidPath=path.join(__dirname,"public/admin");
var reloadTimer=null;
var reloadTimerWebpack=null;
gulp.task("bowserSync", function() {
var files = [
'views/**/*.html',
'views/**/*.css',
'views/**/*.js',
'views/**/*.ejs',
'public/admin/js/*.js',
'public/admin/*.html'
];
bowserSync.init({
files: files,
server: {
baseDir: "./public/admin"
},
port:3000
});
gulp.watch(files).on("change", function(cb){
clearTimeout(reloadTimer);
reloadTimer=null;
reloadTimer=setTimeout(function(){
reload();
},500);
});
});
gulp.task('nodemon', function() {
return nodemon({
script: 'app',
ext: "js",
ignore: ["views/*", "admin/*"],
watch: "./"
// tasks:["bowserSync"]
}).on('start', function() {
console.log("nonman start");
});
});
gulp.task("webpack",function() {
try{
gulp.src(appIndex)
.pipe(webpackStream(webpackConfig))
.pipe(gulp.dest(webpackBulidPath));
}catch(e){
console.log(e);
}
});
gulp.task("app_run",function(){
cmd.get("node app",function(data){
console.log(data);
});
})
gulp.task("clear_map",function(cb){
del([
'admin/*.map',
'admin/js/chunk/*.map'
],cb);
});
gulp.task("webpack",function(){
gulp.watch(path.join(webpackBulidPath,"src/**")).on("change",function(cb){
cmd.get("cd public/admin & webpack");
});
});
gulp.task("default", ["nodemon"],function(){
// gulp.watch(path.join(webpackBulidPath,"src/*"),['webpack']);
});