我有这个 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 中的前端文件,则 gulp 会重新启动服务器。
如何解决这个问题?
最佳答案
我使用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...'));
})
关于javascript - 当我更改前端(Angularjs) Controller 文件时,Gulp 重新启动服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48031404/