How can I use a glob to ignore files that start with an underscore?

不羁的心 提交于 2019-11-29 03:19:19

If Gulp wildcards are like shell wildcards:

content/css/[^_]*.css

The ^ at the beginning of a character set means to match any characters not in the set.

You can add a second glob whitch will filter files or folders with an underscore.

For ignore folders I use:

gulp.src(['./src/**/*.html', '!**/_*/**'])

'!**/_*/**' will filter folders that start with an underscore.

Use this plugin https://github.com/robrich/gulp-ignore

var gulpIgnore = require('gulp-ignore');
var condition = '_*.css'; //exclude condition

gulp.task('less', function() {
  gulp.src('content/less/*.less')
    .pipe(gulpIgnore.exclude(condition))
    .pipe(less())
    .pipe(gulp.dest('/dist/'));
});

I think gulp supports file glob not full-regex, But You can give a try to content/css/[^_]*.less

You could use this regex.

content/css/[^_].*\.css

Add $ at the last if necessary.

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