Excluding certain directories gulp-inject
Ignore bower_components
when included 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 to specify which files to include in mine sources
?
source to share
I believe order matters. For example, let's say I have a folder tests
inside my folder client
where all client code lives. I don't want to include my specs in the index.html
one I generate.
I originally had
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});
but it was still injecting specs into my html! The problem was when I was telling gulp to include all client
folders AFTER I said to exclude one of the folders client
. So I just had to put the excluded folder at the end to fix the problem.
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});
source to share