排除某些目录gulp-inject

时间:2015-06-28 21:16:02

标签: javascript node.js gulp gulp-inject

在包含bower_componentscss个文件

时忽略javascript
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

2 个答案:

答案 0 :(得分:3)

像这样排除scl(0.5f)

bower_components

答案 1 :(得分:0)

我认为订单很重要。例如,假设我的tests文件夹中有一个client文件夹,其中包含所有客户端代码。我不想在我正在生成的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个文件夹 AFTER 我告诉它排除其中一个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});