Web字体未在生产模式下通过资产管道加载

时间:2016-04-17 18:39:00

标签: ruby-on-rails asset-pipeline

我试图将myfonts.com中的一些webfonts加载到我在DigitalOcean上运行的rails应用程序中。它似乎可以很好地预编译,并且可以在开发中本地工作'模式,但不加载生产中的文件'模式。

这些问题的其他答案指向资产管道,但解决方案没有帮助。

我的文件夹结构如下所示:

app
|assets
||fonts
|||*various font files*

main.scss

@import url("//hello.myfonts.net/count/30b86b");


@font-face {
    font-family: 'SofiaProExtraLight';
    src: asset-url('30B86B_0_0.eot');
    src: asset-url('30B86B_0_0.eot?#iefix') format('embedded-opentype'),asset-url('30B86B_0_0.woff2') format('woff2'),asset-url('30B86B_0_0.woff') format('woff'),asset-url('30B86B_0_0.ttf') format('truetype');
}


@font-face {
    font-family: 'SofiaProSemiBold';
    src: asset-url('30B86B_1_0.eot');
    src: asset-url('30B86B_1_0.eot?#iefix') format('embedded-opentype'),asset-url('30B86B_1_0.woff2') format('woff2'),asset-url('30B86B_1_0.woff') format('woff'),asset-url('30B86B_1_0.ttf') format('truetype');
}


@font-face {
    font-family: 'SofiaProRegular';
    src: asset-url('30B86B_2_0.eot');
    src: asset-url('30B86B_2_0.eot?#iefix') format('embedded-opentype'),asset-url('30B86B_2_0.woff2') format('woff2'),asset-url('30B86B_2_0.woff') format('woff'),asset-url('30B86B_2_0.ttf') format('truetype');
}

1 个答案:

答案 0 :(得分:1)

只需将其添加到application.rb

即可
module MyApp
  class Application < Rails::Application
    # ...
    config.assets.paths += %w(fonts)
  end
end