-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
77 lines (55 loc) · 1.32 KB
/
Copy pathgulpfile.js
File metadata and controls
77 lines (55 loc) · 1.32 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
var gulp = require('gulp'),
path = require('path');
var uglify = require('gulp-uglify');
var pump = require('pump');
gulp.task('compress', function (cb) {
pump([
gulp.src('lib/*.js'),
uglify(),
gulp.dest('dist')
],
cb
);
});
var jade = require('gulp-jade'),
server = require('gulp-develop-server'),
livereload = require('gulp-livereload');
livereload({
port: 35729,
start: true
});
var options = {
path: './app.js'
};
var serverFiles = [
'./app.js',
'./routes/**/*.js',
'./mongodb/**/*.js'
];
var htmlCssJsFile = [
'./views/**/*.jade',
'./public/style/**.css',
'./public/js/*.js'
];
gulp.task('server:start', function() {
server.listen(options);
});
gulp.task('watch', function() {
gulp.watch('.views/*.*', function() {
livereload();
});
});
// If server scripts change, restart the server and then livereload.
gulp.task('default', ['server:start'], function() {
// 重启Server
function restart(file) {
server.changed(function(error) {
if (!error) livereload.changed(file.path);
});
}
gulp.watch(serverFiles).on('change', restart);
// 刷新页面,没生效
// gulp.watch(htmlCssJsFile).on('change', function(file) {
// livereload.changed(file.path);
// });
});