我已将config.rb文件设置如下
http_path = "/"
css_dir = ""
sass_dir = "sass"
images_dir = "images"
fonts_dir = 'fonts'
fonts_path = ""
javascripts_dir = "js"
这是我的目录路径
在项目根
中的style.css 字体/我的字体 上海社会科学院/ style.sass 图像/我的 - 所有图像
现在,当我尝试使用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');
}
答案 0 :(得分: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
答案 1 :(得分: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"