Gulp glob to ignore file types and not copy empty folders

做~自己de王妃 提交于 2019-12-05 08:33:52

Since gulp.src accepts almost the same options as node-glob, you can add nodir: trueas an option:

gulp.src('apps/*/static_src/**/!(*.js|*.coffee)', { nodir: true })

This will preserve the dir structure from src, but omit empty ones.

gulp.task('copyfiles', function(){
    gulp.src(['apps/*/static_src/**/*','!apps/*/static_src/{js/, js/**}'])
        .pipe(gulp.dest('dest'));
});

I think you need a pattern '!apps/*/static_src/{js/, js/**}' that matches the directory as well as the files inside to prevent ommiting an empty directory. I am not sure if there is a pattern to match a directory only by specifying its content.

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