问题描述
我创建了一个忽略一组目录中的javascript和coffeescript文件的gulp。我想它将所有其他文件复制到一个工作正常的目录。唯一的问题是,当只有javascript或coffeescript文件时,它会复制一个空文件夹。任何想法如何将这个glob修改为不复制空文件夹?
gulp.task('copyfiles',function(){
gulp.src('apps / * / static_src / ** /!(*。js | * .coffee)')
.pipe(gulp.dest('dest'));
});
示例源文件:
apps / appname / static_src / images / image.jpg
apps / appname / static_src / js / script.js
预期输出:
dest / static_src / images / image.jpg
当前输出:
dest / static_src / images / image.jpg
dest / static_src / js /
由于 gulp.src
接受几乎相同的选项,您可以添加 nodir:true
作为选项:
gulp.src('apps / * / static_src / ** /!(*。js | * .coffee)' ,{nodir:true})
这将保留src的dir结构,但省略空的结构。
I have created a glob for gulp which ignores javascript and coffeescript files within a set of directories. I'd like it to copy all other files into a directory which works fine. The only problem is that when there are only javascript or coffeescript files it copies an empty folder. Any ideas how this glob could be amended to not copy empty folders?
gulp.task('copyfiles', function(){
gulp.src('apps/*/static_src/**/!(*.js|*.coffee)')
.pipe(gulp.dest('dest'));
});
Example source files:
apps/appname/static_src/images/image.jpg
apps/appname/static_src/js/script.js
Expected output:
dest/static_src/images/image.jpg
Current output:
dest/static_src/images/image.jpg
dest/static_src/js/
Since gulp.src
accepts almost the same options as node-glob, you can add nodir: true
as an option:
gulp.src('apps/*/static_src/**/!(*.js|*.coffee)', { nodir: true })
This will preserve the dir structure from src, but omit empty ones.
这篇关于Gulp glob忽略文件类型,不复制空文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!