When it comes to minimizing CSS, I rely on gulp-clean-css within a gulp.task.
The file path I'm working with is css/mehr.css, and after minification, the new path becomes css/mehr.min.css
However, upon running the task :
gulp minify_css_task
An issue arises where mehr.min.css is created, but it ends up empty!
Here's the output:
[11:45:01] Using gulpfile ~/mehr/gulpfile.js
[11:45:01] Starting 'minify_css_task'...
Original size of mehr.css: 7192
Minified size of mehr.css: 0
[11:45:02] Finished 'minify_css_task' after 68 ms
In my gulpfile.js:
var cleanCSS = require('gulp-clean-css');
gulp.task('minify_css_task',[other_task], function() {
return gulp.src('css/mehr.css')
.pipe(cleanCSS({debug: true}, function(details) {
compatibility: 'ie8';
console.log('Original size of '+ details.name + ': ' + details.stats.originalSize);
console.log('Minified size of '+ details.name + ': ' + details.stats.minifiedSize);
}))
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('css'))
.pipe(browserSync.reload({
stream: true
}))
});
I've made sure to use the latest version of gulp-clean-css:
npm view gulp-clean-css description dist-tags.latest version
And here's the detailed information:
description = 'Minify css with clean-css.'
dist-tags.latest = '3.9.0'
version = '3.9.0'