Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

grunt-contrib-cssmin - how to remove comments from minified css

Im using cssmin to minify css files.

my config like this:

module.exports = function(grunt) {

    grunt.config.set('cssmin', {
        site: {
            src: ['.tmp/public/concat/site.css'],
            dest: '.tmp/public/min/site.min.css'
        }
    });

    grunt.loadNpmTasks('grunt-contrib-cssmin');
};

But output minified css files has comments. Is it possible to configure cssmin to remove comment from source css files?

Thank you.

like image 743
kabiev Avatar asked Jan 07 '15 18:01

kabiev


2 Answers

Set keepSpecialComments to zero, for removing all comments.

grunt.config.set('cssmin', {
    options: {
        keepSpecialComments: 0
    },
    site: {
        src: ['.tmp/public/concat/site.css'],
        dest: '.tmp/public/min/site.min.css'
    }
});

For future reference: grunt-contrib-cssmin uses clean-css options.

like image 106
Rigotti Avatar answered Nov 18 '22 03:11

Rigotti


It's an old question but now you can use it like this:

module.exports = function(grunt) {
  grunt.config.set('cssmin', {
    options: {
      level: {
        1: {
          specialComments: 0
        }
      }
    },
    site: {
      src: ['.tmp/public/concat/site.css'],
      dest: '.tmp/public/min/site.min.css'
    }
  });
  grunt.loadNpmTasks('grunt-contrib-cssmin');
};

clean-css #How to apply level 1 & 2 optimizations at the same time?

like image 26
Vidyu Avatar answered Nov 18 '22 04:11

Vidyu