繁体   English   中英

排除某些目录gulp-inject

[英]excluding certain directories gulp-inject

在包含cssjavascript文件时忽略bower_components

gulp.task('files', function(){
    var target = gulp.src("./client/index.html");
    var sources = gulp.src(["./client/**/*.js", "./client/**/*.css"], {read: false});

    target.pipe(inject(sources))
        .pipe(gulp.dest("./client"))    
});

我不想在index.html中包含client/bower_components 有没有办法可以指定要包含在我的sources文件?

https://github.com/klei/gulp-inject#optionsignorepath

像这样排除bower_components

var sources = gulp.src(["!./client/bower_components/**/*"
                 "./client/**/*.js", "./client/**/*.css"], {read: false});

我相信这个命令很重要。 例如,假设我的client文件夹中有一个tests文件夹,其中所有客户端代码都存在。 我不想在我生成的index.html包含我的规范。

原来我有

var sources = gulp.src([
    '!./client/tests/**/*', // exclude the specs up front, didn't work
    './client/config/app.js',
    './client/config/*.js',
    './client/**/*.js', // conflicts with the tests exclusion   
    './client/**/*.css'
], {read: false});

但它仍然将规格注入我的HTML! 问题是我告诉gulp在我告诉它排除其中一个client文件夹之后包含所有client client文件夹。 所以我只需要将排除的文件夹放在最后以解决问题。

var sources = gulp.src([
    './client/config/app.js',
    './client/config/*.js',
    './client/**/*.js',
    './client/**/*.css',
    '!./client/tests/**/*' // exclude the specs at the end, works!
], {read: false});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM