function watch(){ var watcher = gulp.watch(scriptsGlob, scripts); watcher.on('change', function (event) { if (event.type === 'deleted') { delete cache.caches['scripts'][event.path]; remember.forget('scripts', event.path); } }); }
gulp.task('watch',watch);
使用效果
未开启增量编译
1 2 3 4 5 6 7 8 9 10 11 12
[18:35:26] Using gulpfile D:\blog\gulpfile.js [18:35:26] Starting 'default'... [18:35:26] Starting 'minifyJS'... [18:35:26] Starting 'minifyHtml'... [18:35:26] Starting 'minifyCss'... [18:35:26] Starting 'minifyImgs'... [18:35:28] Finished 'minifyJS' after 2.2 s [18:35:29] gulp-imagemin: Minified 17 images (saved 0 B - 0%) [18:35:29] Finished 'minifyImgs' after 3.32 s [18:35:29] Finished 'minifyCss' after 3.66 s [18:35:30] Finished 'minifyHtml' after 4.44 s [18:35:30] Finished 'default' after 4.45 s
开启增量编译
1 2 3 4 5 6 7 8 9 10 11 12
[18:41:27] Using gulpfile D:\blog\gulpfile.js [18:41:27] Starting 'default'... [18:41:27] Starting 'minifyJS'... [18:41:27] Starting 'minifyHtml'... [18:41:27] Starting 'minifyCss'... [18:41:27] Starting 'minifyImgs'... [18:41:28] Finished 'minifyJS' after 879 ms [18:41:28] gulp-imagemin: Minified 0 images [18:41:28] Finished 'minifyImgs' after 889 ms [18:41:28] Finished 'minifyCss' after 897 ms [18:41:28] Finished 'minifyHtml' after 912 ms [18:41:28] Finished 'default' after 916 ms