Best way to filter files in gulp.watch?

旧城冷巷雨未停 提交于 2019-11-30 10:28:30

问题


I would like to watch all, but the .min.ext files in my directories with gulp.js. What is the best way to filter out those?

Example:

gulp.task('watch', function(e) {
   gulp.watch('./js/*.js', ['css']); // don't want to watch .min.js files. what is best way?
});

EDIT: If can't be done without external packages, which one is the most reputable?


回答1:


gulp.watch internally uses vinyl-fs (see source), which uses gaze, which uses itself minimatch, so you should be able to ignore some files using !./js/*.min.*.

In fact, this is even described in vinyl-fs's README:

fs.src(["./js/**/*.js", "!./js/vendor/*.js"])
[…]


来源:https://stackoverflow.com/questions/21605592/best-way-to-filter-files-in-gulp-watch

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!