config.rb为SASS字体目录路径添加斜杠

Cod*_*ver 4 sass compass-sass

我已经设置了config.rb文件,如下所示

http_path = "/"
css_dir = ""
sass_dir = "sass"
images_dir = "images"
fonts_dir = 'fonts'
fonts_path = ""
javascripts_dir = "js"
Run Code Online (Sandbox Code Playgroud)

这是我的目录路径

在项目根目录中

style.css fonts/my-fonts sass/style.sass images/my-all-images

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

上海社会科学院

+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"))
Run Code Online (Sandbox Code Playgroud)

生成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');
}
Run Code Online (Sandbox Code Playgroud)

小智 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
Run Code Online (Sandbox Code Playgroud)