|
Gulp.watch()会返回我们熟知的watcher。我们可以利用watcher来监听额外的事件或者向watch中添加文件。
例如,在执行一系列任务和调用一个函数时,你就可以在返回的watcher中添加监听change事件: 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事件,还可以监听很多其他的事件:
Watcher对象也包含了一些可以调用的方法:
更多详情,请看: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/ 转自:https://www.cnblogs.com/ayseeing/p/4118574.html |
|
|