簡體   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