15

I am using gulp minifyCss to minify my css to reduce filesize. My gulp task looks something like this:

gulp.task('minify-css', function() {
  return gulp.src('styles/*.css')
    .pipe(concatCss("all.css").on('error', standardHandler))
    .pipe(minifyCss().on('error', standardHandler))
    .pipe(gulp.dest('dist'));
});

It works fine and output as expected. However, it does not remove special comments /*! comment */

How can I get minifyCss to have special comments removed?

scniro
  • 16,844
  • 8
  • 62
  • 106
user1995781
  • 19,085
  • 45
  • 135
  • 236
  • Just an FYI `gulp-minify-css` has been [deprecated](https://www.npmjs.com/package/gulp-minify-css) in favor of [gulp-clean-css](https://github.com/scniro/gulp-clean-css) – scniro Mar 02 '16 at 00:39

2 Answers2

16

You should set keepSpecialComments option:

gulp.task('minify-css', function() {
  return gulp.src('styles/*.css')
    .pipe(concatCss("all.css").on('error', standardHandler))
    .pipe(minifyCss({keepSpecialComments : 0}).on('error', standardHandler))
    .pipe(gulp.dest('dist'));
});
Ufuk Hacıoğulları
  • 37,978
  • 12
  • 114
  • 156
1

Now Ufuk's variant not working. Try this:

.pipe(cleanCSS({level: {1: {specialComments: false}}}))
GrimCap
  • 31
  • 5