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
?
Exclude the bower_components
like this.
var sources = gulp.src(["!./client/bower_components/**/*"
"./client/**/*.js", "./client/**/*.css"], {read: false});
I believe that the order matters. For example, let's say I have a tests
folder inside of my client
folder where all the client-side code lives. I don't want to include my specs in the index.html
I am generating.
Originally I 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 the specs into my html! The problem was that I was telling gulp to include all of the client
folders AFTER I told it to exclude one of the client
folders. So I just had to put the excluded folder at the end to fix the issue.
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});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.