4

我已将 config.rb 文件设置如下

http_path = "/"
css_dir = ""
sass_dir = "sass"
images_dir = "images"
fonts_dir = 'fonts'
fonts_path = ""
javascripts_dir = "js"

这是我的目录路径

在项目根目录中

style.css 字体/my-fonts sass/style.sass 图像/my-all-images

现在,当我尝试使用 font-face 添加字体时,它正在为字体目录添加前导斜杠,/fonts但我只想要它fonts

SASS

+font-face("Ubuntu", font-files("ubuntu/ubuntu-r-webfont.eot", "ubuntu/ubuntu-r-webfont.eot?#iefix", "ubuntu/ubuntu-r-webfont.woff", "ubuntu/ubuntu-r-webfont.ttf", "ubuntu/ubuntu-r-webfont.svg#ubunturegular"))

生成 CSS

@font-face {
  font-family: "Ubuntu";
  src: url('/fonts/ubuntu/ubuntu-r-webfont.eot') format('embedded-opentype'), url('/fonts/ubuntu/ubuntu-r-webfont.eot?#iefix') format('embedded-opentype'), url('/fonts/ubuntu/ubuntu-r-webfont.woff') format('woff'), url('/fonts/ubuntu/ubuntu-r-webfont.ttf') format('truetype'), url('/fonts/ubuntu/ubuntu-r-webfont.svg#ubunturegular') format('svg');
}
4

2 回答 2

10

您可以relative_assets = true在配置文件中的路径设置后立即设置。

这是一个用于处理相关资产的示例配置示例。

# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "app/css"
sass_dir = "app/css/sass"
images_dir = "app/img"
javascripts_dir = "app/js"
fonts_dir = "app/css/fonts"

output_style = :nested
environment = :development

relative_assets = true
于 2013-08-31T06:38:50.097 回答
0
You can set http_fonts_path = "fonts" right after path setting in config file.

Here is a sample config example to work.
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "css"
sass_dir = "scss"
images_dir = "images"
javascripts_dir = "js"
http_fonts_path = "fonts"
于 2018-03-29T13:30:21.703 回答