【问题标题】:Sass - Web Compiler replaces Url as relatives urlsSass - Web 编译器将 Url 替换为亲戚 url
【发布时间】:2023-03-31 23:21:01
【问题描述】:

我在使用 VS2015 Update 1 和 Sass 的 Web 编译器时遇到问题。

在我的 Scss 文件中,我将一些图像声明为背景。

例子:

.example {
     background-image: url(images/ex.jpg);
}

文件compilerconfig.json中,outPutFile不在同一目录下。 在文件 compilerconfig.json.defaults 中,我在 sass 部分将 relativeUrls 设置为 false。 当我编译时,url 变成相对的:

.example {
         background-image: url(../../../../../images/ex.jpg);
    } 

我对导入的文件有同样的问题。

有没有办法解决这个问题?

【问题讨论】:

  • 一个简单的搜索说,在SASS选项中可以用:template_location设置文档根目录
  • 我使用的是 VS 扩展 WebCompiler,而不是带有文件夹 sass、样式表的 ruby​​ watcher... 我编辑我的 scss 文件,我保存,VS 扩展生成 css 和 min.css 文件。那么,我在哪里可以设置选项?

标签: css sass web-compiler


【解决方案1】:

我找到了如何禁用相对网址: 该选项不是在文件 compilerconfig.json.defaults 中设置,而是在 compilerconfig.json 中设置:

[
  {
    "outputFile": "../../../../../inetpub/wwwroot/ui/skins/test.css",
    "inputFile": "Web/Stylesheets/test.scss",
    "minify": {
      "termSemicolons": true
    },
    "options": {
      "relativeUrls": false,
      "lineFeed": "crlf"
    }
  }
]

【讨论】:

  • 我没有听懂您使用网络编译器的部分,但感谢您添加解决方案。
猜你喜欢
  • 2015-07-08
  • 1970-01-01
  • 2022-07-09
  • 2017-03-16
  • 2014-06-18
  • 2016-11-08
  • 2017-02-26
  • 2018-07-27
  • 2012-01-22
相关资源
最近更新 更多