Search code examples
javascriptnode.jsgulpgulp-inject

excluding certain directories gulp-inject


Ignoring bower_components while including css and javascript files

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

I don't want to include client/bower_components in my index.html? Is there a way i can specify what files to include in my sources?

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


Solution

  • Exclude the bower_components like this.

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