// 定义web服务模块,增加浏览器同步浏览
gulp.task('browser-sync', ['nodemon'], function () {
console.log("自动自行刷新-------------------------");
browsersync.init(null, {
proxy: 'http://localhost:3000',
browser: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" ,//在谷歌下面打开
notify: false,
port: 3001,
files: [dist.root+"**/*"]
});
});
gulp.task('nodemon', function (cb) {
var called = false;
return nodemon({
script: 'bin/www'
}).on('start', function () {
if (!called) {
cb();
called = true;
}
});
});
How to use gulp-nodemon internal deletion to restart the express server
Nodemon itself can monitor js file changes and automatically restart the nodejs service. nodemon only needs to be started once.
browser-sync task, no need to start nodemon every time.