在 gulp.watch 中过滤文件的最佳方法? [英] Best way to filter files in gulp.watch?

查看:15
本文介绍了在 gulp.watch 中过滤文件的最佳方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想查看所有文件,但 gulp.js 目录中的 .min.ext 文件除外.过滤掉这些的最佳方法是什么?

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?

例子:

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

如果没有外部软件包就无法完成,那么哪一个是最有信誉的?

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

推荐答案

gulp.watch 内部使用 <代码>vinyl-fs(参见来源),它使用 gaze,它使用自身 minimatch,所以你应该可以使用 !./js/*.min.* 忽略一些文件.

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.*.

事实上,这甚至在 vinyl-fs 的 README 中都有描述:

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

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

这篇关于在 gulp.watch 中过滤文件的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆