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

标签 javascript angularjs node.js 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...'));
   })
})

只有当我的 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/

相关文章:

javascript - 使消息返回所有数据库行

javascript - 如何检查 if 语句的条件以查看其是否正常工作?

javascript - 本地存储数据未进入 Angularjs 中的头文件

javascript - 当在浏览器中直接访问 URL 但单击到时, Angular 路由不起作用?

javascript - 当元素进入 Angular JS View 时,如何在滚动上显示元素

javascript - 从 IndexedDB 中删除多个项目

ruby-on-rails - 什么时候线程框架比事件驱动框架更好? (即,什么时候 rails 比 node.js 更好?)

javascript - 避免 Javascript 中变量/函数冲突的方法(没有 jQuery 插件)

javascript - 未捕获的类型错误 : Cannot read property 'retrieveMultiple' of undefined

javascript - ionic 2 : access main page's services from popover callback