3

bower_components包含cssjavascript文件时忽略

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"))    
});

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

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

4

2 回答 2

3

排除bower_components此类。

var sources = gulp.src(["!./client/bower_components/**/*"
                 "./client/**/*.js", "./client/**/*.css"], {read: false});
于 2015-06-28T21:23:48.417 回答
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文件夹之后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});
于 2016-01-05T16:36:21.187 回答