Answer the question
In order to leave comments, you need to log in
How to include only the necessary js and css when building with Gulp?
Hello. I wondered about building a project on Gulp. When automatically connecting js and css through Bower, paths like "bower_components/normalize-css/normalize.css" are written to the downloaded packages, and there are a lot of unnecessary files. It is possible to pull files from packages with the main-bower-files plugin, but the paths will remain until the full packages. How can you rewrite paths?
Answer the question
In order to leave comments, you need to log in
If you use main-bower-files then include only those files that you specified in the
example task:
gulp.task('styles:vendor', function() {
gulp.src(mainBowerFiles({
"overrides": {
"normalize.css": {
"main": "./normalize.css"
},
"magnific-popup": {
"main": "./dist/magnific-popup.css"
},
"bootstrap": {
main: [
'./dist/css/bootstrap.css',
'./dist/fonts/*.*'
]
}
}
}))
.pipe(cssFilter)
.pipe(concat('vendor.css'))
.pipe(gulpIf(env !== 'dev', minifyCSS()))
.pipe(gulp.dest(outputDir + 'css'))
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question