当我更改前端(Angularjs)控制器文件时,Gulp重新启动服务器



我有这个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...'));
   })
})

我想重新加载 gulp 只有当我的服务器.js(服务器端(文件更改时,

但是如果我在 AngularJS 控制器.js中更改了前端文件,请 gulp 重新启动服务器。

如何解决这个问题?

我使用 nodemon 选项手表

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...'));
})

最新更新