1.0.6 • Published 7 years ago
gulp-nuiwatch v1.0.6
Installation
Install package with NPM and add it to your development dependencies:
npm install --save-dev gulp-nuiwatch
Usage
var gulp = require('gulp');
var nui = require('gulp-nui');
var nuiwatch = require('gulp-nuiwatch');
gulp.task('watch', function(){
nuiwatch(['./pages/**/.*html'], function(watcher){
gulp.src('./pages/**/*.{css,js}')
.pipe(nui({
watcher:watcher
}))
.pipe(gulp.dest('./pages/'))
})
})
gulp.task('default', ['watch'])
Infomation
该模块其实就是gulp-watch,非常感谢作者提供这么好的工具。
不同的地方是将内部的slash模块移除了,移除的原因是在使用unwatch移除某个文件的监听,再add该文件后,该文件并没有被监听,查看源码后发现chokidar模块中unwatch是将文件路径存到_ignoredPaths对象中,路径以“\”分隔,add的时候其实将_ignoredPaths中该路径删除,但是add的路径是以“/”分隔的,就导致没删掉,所以才没有没监听到。
另外将默认参数usePolling设置为了true,callback参数变为了2个,第一个参数为outputStream,gulp-nui模块watcher参数值就是它,第二个参数为file和原来一样。