我有这个gulpfile.js
// Dependencies
var gulp = require('gulp');
var nodemon = require('gulp-nodemon');
// var notify = require('gulp-notify');
var livereload = require('gulp-livereload');
// Task
gulp.task('default', function () {
// listen for changes
livereload.listen();
// configure nodemon
nodemon({
// the script to run the app
script: 'server.js',
ext: 'js'
}).on('restart', function () {
// when the app has restarted, run livereload.
gulp.src('server.js')
.pipe(livereload())
// .pipe(notify('Reloading page, please wait...'));
})
})
我想只在我的server.js(服务器端)文件发生变化时才重新加载gulp,
但如果我在angularjs controller.js中更改了前端文件,请重新启动服务器。
怎么解决这个?
我使用nodemon选项watch
nodemon({
// the script to run the app
script: 'server.js',
// comment or remove this line ext: 'js',
ignore: ['js/controller.js'], // you can also specify directories/files to ignore
// add watch array here
watch: [
//directories that you want to watch ex: src/**/*.js
'server.js' // you can be as specific as you want try this.
]
}).on('restart', function () {
// when the app has restarted, run livereload.
gulp.src('server.js')
.pipe(livereload())
// .pipe(notify('Reloading page, please wait...'));
})