Gulp.watch()会返回咱们熟知的watcher。咱们能够利用watcher来监听额外的事件或者向watch中添加文件。html
例如,在执行一系列任务和调用一个函数时,你就能够在返回的watcher中添加监听change事件:git
var watcher = gulp.watch('templates/*.tmpl.html', ['build']); watcher.on('change', function (event) { console.log('Event type: ' + event.type); // added, changed, or deleted console.log('Event path: ' + event.path); // The path of the modified file });
除了change事件,还能够监听不少其余的事件:github
Watcher对象也包含了一些能够调用的方法:gulp
更多详情,请看:http://www.tuicool.com/articles/AzI3Ib函数
其余文章:http://markpop.github.io/2014/09/17/Gulp%E5%85%A5%E9%97%A8%E6%95%99%E7%A8%8B/ui