Glob匹配,排除所有JS文件

时间:2022-09-01 23:34:13

I'm a new user to gulp.js. I'd like to move all of my non-javascript files to a build directory. What I've got right now is this:

我是gulp.js的新用户。我想将所有非javascript文件移动到一个构建目录。我现在得到的是:

//Test copy
gulp.task('test-copy', function() {
    gulp.src(['myProject/src/**/*.!(js|map|src)'])
        .pipe(gulp.dest('myProject/build'));
});


//Results for various files
myProject/css/style.css //Copied - GOOD
myProject/html/index.html //Copied - GOOD
myProject/js/foo.js //Not Copied - GOOD
myProject/js/bar.min.js //Copied - BAD!
myProject/js/jquery-2.0.3.min.js //Copied - BAD!
myProject/js/jquery-2.0.3.min.map //Copied - BAD!

As you can see, it only matches after the first dot in the file path string, not the last one, as I'd like. How can I modify the glob search string to behave as I'd like?

正如您所看到的,它只匹配文件路径字符串中的第一个点,而不是我想要的最后一个点。如何修改glob搜索字符串,使其按照自己的意愿运行?

1 个解决方案

#1


102  

Try this glob pattern:

试试这一团模式:

myProject/src/**/!(*.js|*.map|*.src)

#1


102  

Try this glob pattern:

试试这一团模式:

myProject/src/**/!(*.js|*.map|*.src)