【问题标题】:Grunt : Usemin prepare, options for cssminGrunt : Usemin prepare, cssmin 的选项
【发布时间】:2015-06-17 13:08:30
【问题描述】:

我在我的 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,我不知道如何添加此参数。

有什么想法吗?

谢谢!

【问题讨论】:

    标签: gruntjs grunt-usemin grunt-contrib-cssmin


    【解决方案1】:

    要在生成的 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
                };
              }
            }]
          }
        }
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-27
      • 2012-11-04
      • 2013-12-29
      相关资源
      最近更新 更多