What is the best way of minify multiple css files into one?
The gulp task below causing two issues after the minification and concatenation:
- bootstraps glyphicons that I use have disappeared.
- some of my styles are broken. The task seems to have re-arranged the position of some styles, for instance
.footer{...}
was placed belowhtml{...}
but it is now abovehtml{...}
. How can i stop it from rearranging them?
gulpfile:
gulp.task('minify-css', function() {
return gulp.src([
'node_modules/bootstrap/dist/css/bootstrap.css',
'vendor/jquery-ui-1.12.1/jquery-ui.min.css',
'node_modules/bootstrap/dist/css/bootstrap-theme.css',
'node_modules/jasny-bootstrap/dist/css/jasny-bootstrap.css',
'css/style.css',
])
.pipe(sourcemaps.init())
.pipe(cleanCSS({debug: true}))
.pipe(sourcemaps.write())
.pipe(concat('bundle.min.css'))
.pipe(gulp.dest('dist'));
});
Any ideas?
I don't know if it help you but I think you could use SASS preprocessing by gulp-sass. There you could import all of your dependencies and let gulp-sass to minify the result. I have similar approach in my gulp devstack. SASS (libsass) can import *.css files, e.g. in your main.scss you can write
Note that without .css extension! If you not familiar with SASS I recommend to give it a chance.