Grunt构建错误地优化CSS URL

时间:2014-04-26 03:51:11

标签: css backbone.js backbone-boilerplate

我正在使用Backbone Boilerplate并且我添加了bower Ratchet 2. *依赖项,然后我将它从我的styles / index.css文件中导入它的bower origin文件夹:

@import "../../vendor/bower/ratchet/dist/css/ratchet.css";

这样可以正确地抓取文件,但出于某种原因,在压缩它时会更改@ font-face选择器中的url。

原始选择器如下所示:

@font-face {
  font-family: Ratchicons;
  font-style: normal;
  font-weight: normal;
  src: url("app/fonts/ratchicons.eot");
  src: url("app/fonts/ratchicons.eot?#iefix") format("embedded-opentype"), 
       url("app/fonts/ratchicons.woff") format("woff"), 
       url("app/fonts/ratchicons.ttf") format("truetype"), 
       url("app/fonts/ratchicons.svg#svgFontName") format("svg");

运行grunt任务后,我对此选择器的新优化style.css如下所示:

@font-face {
    font-family: Ratchicons; font-style: normal; font-weight: normal; 
    src: url("/app/img/vendor/bower/ratchet/dist/css/app/fonts/ratchicons.eot?#iefix") format("embedded-opentype"), 
         url("app/fonts/ratchicons.woff") format("woff"), 
         url("app/fonts/ratchicons.ttf") format("truetype"), 
         url("app/fonts/ratchicons.svg#svgFontName") format("svg");
}

(添加了换行符以供显示)

你会注意到整个第一行:

src: url("app/fonts/ratchicons.eot");

已完全删除,下一行应为:

src: url("app/fonts/ratchicons.eot?#iefix") format("embedded-opentype"),

但已成为:

src: url("/app/img/vendor/bower/ratchet/dist/css/app/fonts/ratchicons.eot?#iefix") format("embedded-opentype"), 

我无法理解或解释为什么会这样,但我需要解决它。

我检查了我的gruntfile的样式部分,它看起来像这样:

styles: {
  // Out the concatenated contents of the following styles into the below
  // development file path.
  "dist/styles.css": {
    // Point this to where your `index.css` file is location.
    src: "app/styles/index.css",

    // The relative path to use for the @imports.
    paths: ["app/styles"],

    // Rewrite image paths during release to be relative to the `img`
    // directory.
    forceRelative: "/app/img/"
  }
},

我假设由于某种原因,样式优化器将forceRelative网址添加到../ fonts / fontfile 的原始网址中,但我无法解释原因或做什么。< / p>

帮助表示赞赏。

0 个答案:

没有答案