Grunt : Usemin prepare, options for cssmin

735 views Asked by At

I'm using usemin in my Grunt file.

I'd like to use purifycss.

BUT, i get this error when running grunt : Warning: Please check the validity of the CSS block starting from the line #1 Use --force to continue.

I think it's because Font Awesome is the first library in my project and it has the following css header : /*! * Font Awesome 4.3.0 by @davegandy - http://fontawesome.io - @fontawesome * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) */

So i think i should use the argument : keepSpecialComments: 0 for cssmin.

My problem is that the usemin prepare task is doing the cssmin and i don't know how to add this argument.

Any idea ?

Thanks !

1

There are 1 answers

0
Prayag Verma On BEST ANSWER

To add options in the generated config of the cssmin task , you will need to use the flow option in useminPrepare.

useminPrepare: {
  html: 'index.html',
  options: {
    flow: {
      steps: {
        css: ['cssmin']
      },
      post: {
        css: [{
          name: 'cssmin',
          createConfig: function (context, block) {
            var generated = context.options.generated;
            generated.options = {
              keepSpecialComments: 0
            };
          }
        }]
      }
    }
  }
}