let gulp=require('gulp'),
	nodemon=require('gulp-nodemon'),
	browser=require('browser-sync');
let reload=browser.reload;
gulp.task('serve',function(){
	browser.init({
		proxy:'http://localhost:3000',
		notify:false,
		port:3001
	});
	gulp.watch(["./views/*.pug","./views/**/*.pug","!./views/layout.pug"]).on('change',reload);
});
gulp.task('start',function(){
	nodemon({
		script:'app.js',
		ext:'js html',
		env:{'NODE_ENV':'development'}
	});
});
gulp.task('default',['start','serve']);

通过!排除不需要监听的文件。

一下来自官方文档API页面: http://www.gulpjs.com.cn/docs/api/
gulp.watch(glob[, opts], tasks)
glob
类型: String or Array
一个 glob 字符串,或者一个包含多个 glob 字符串的数组,用来指定具体监控哪些文件的变动。

相关文章:

  • 2021-07-29
  • 2022-01-10
  • 2021-07-27
  • 2022-02-06
  • 2021-10-24
  • 2021-11-05
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-06
  • 2022-12-23
相关资源
相似解决方案