0

我在我的 Grunt 文件中使用了 usemin。

我想使用purifycss。

但是,运行 grunt 时出现此错误: Warning: Please check the validity of the CSS block starting from the line #1 Use --force to continue.

我认为这是因为 Font Awesome 是我项目中的第一个库,它具有以下 css 标头: /*! * Font Awesome 4.3.0 by @davegandy - http://fontawesome.io - @fontawesome * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) */

所以我认为我应该使用参数:keepSpecialComments: 0对于 cssmin。

我的问题是 usemin 准备任务正在执行 cssmin,我不知道如何添加此参数。

任何想法 ?

谢谢 !

4

1 回答 1

3

要在生成的 cssmin 任务配置中添加选项,您需要在 useminPrepare 中使用flow选项。

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
            };
          }
        }]
      }
    }
  }
}
于 2015-06-18T18:43:07.490 回答