在gulp.watch中过滤文件的最佳方法是什么? [英] Best way to filter files in gulp.watch?
本文介绍了在gulp.watch中过滤文件的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用 gulp.js 观察我所有目录中的.min.ext文件。
示例:
gulp.task('watch',function(e){
gulp.watch('./ js / *。js',['css']); //不想看.min。 js文件。什么是最好的方式?
});
编辑:如果没有外部软件包,是最有信誉的?
解决方案
vinyl-fs
(参见来源),它使用 gaze
,它使用自己的 minimatch
,所以你应该可以使用!./ js / * .min。*
来忽略一些文件。
实际上,甚至在 vinyl-fs的自述文件中对此进行了描述:
fs.src([./ js / ** / *。js,!./ js / vendor / *。js])
[...]
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?
解决方案
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"])
[…]
这篇关于在gulp.watch中过滤文件的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文