【问题标题】:Asset pipeline minify adds question mark to CSS header资产管道缩小向 CSS 标头添加问号
【发布时间】:2016-05-30 12:56:04
【问题描述】:

我正在运行一个 Grails 项目,其中 Gradle 使用资产管道插件 (2.9.1),在 Gradle 构建文件中具有以下配置:

assets {
    minifyJs = true
    minifyCss = false
    enableGzip = false
    //excludes = ['**/w3.css']
}

我正在使用 w3.css 样式表,它的开头是这样的:

/* W3.CSS 1.96 by J.E.Refsnes. Do not remove this line. */
*{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-    sizing:border-box}
/* Extract from normalize.css by Nicolas Gallagher and Jonathan Neal     git.io/normalize */
html{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}
...etcetera...

但是当我构建我的项目并将资产放在一起时,我最终会在 w3.css 的开头加上一个额外的问号:

?/* W3.CSS 1.96 by J.E.Refsnes. Do not remove this line. */
*{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-    sizing:border-box}
/* Extract from normalize.css by Nicolas Gallagher and Jonathan Neal     git.io/normalize */
html{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}

如何去掉这个被添加的问号?这是怎么发生的?我已经将资产插件从 2.5.0 升级到了 2.9.1。但这并没有解决问题。有什么我正在监督的吗?这个问号实际上给出了一个问题,即 webkit 边框框元素前面的第一个星号没有被正确拾取。

【问题讨论】:

    标签: css gradle asset-pipeline minify


    【解决方案1】:

    问号可能表示文件编码及其处理方式存在问题。您可以为您的资产管道文件手动set the locale。对于 CSS,它看起来像这样:

    /**
     *= require file1.css
     *= require file2.css
     *= encoding UTF-8
     */
    

    或者对于 Javascript,试试:

    //= require file1.js
    //= require file2.js
    //= encoding UTF-8
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-12-04
      • 2011-12-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-07
      • 2015-01-28
      相关资源
      最近更新 更多