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

问题描述 投票:0回答:1

我正在尝试从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');
}
ruby-on-rails asset-pipeline
1个回答
1
投票

只需将其添加到您的application.rb

module MyApp
  class Application < Rails::Application
    # ...
    config.assets.paths += %w(fonts)
  end
end
© www.soinside.com 2019 - 2024. All rights reserved.