Why the task's output of gulp-clean-css for minify CSS is empty file?

968 views Asked by At

I use gulp-clean-css as a gulp.task to minify CSS.

My file path is css/mehr.css and the path of minified CSS will be css/mehr.min.css

But when I run the task :

gulp minify_css_task

The mehr.min.css is created, but it's empty!

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

and my gulpfile.js is :

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 use latest version of gulp-clean-css :

npm view gulp-clean-css description dist-tags.latest version

output :

description = 'Minify css with clean-css.'
dist-tags.latest = '3.9.0'
version = '3.9.0'
1

There are 1 answers

0
Mojtaba Arvin On

There was /* in top of my css that I had forgot to close it :))