gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 01:55:50 26 4
gpt4 key购买 nike

我有这个 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com