2017-01-21 68 views
2

它在開發過程中非常完美,但在生產過程中沒有問題。它沒有找到下列文件:Rails 5 - 供應商資產未在生產中加載(僅適用於字體)

/assets/fontello.woff
/assets/fontello.ttf

下面是設置:

  1. 字體文件:

enter image description here

  • assets.rb

    Rails.application.config.assets.paths << Rails.root.join('app', 'vendor', 'assets', 'fonts') 
    Rails.application.config.assets.precompile << /\.(?:svg|eot|woff|ttf)\z/ 
    
  • fontello.css

    @font-face { 
        font-family: 'fontello'; 
        src: url('/assets/fontello.eot'); 
        src: url('/assets/fontello.eot#iefix') format('embedded-opentype'), 
        url('/assets/fontello.woff') format('woff'), 
        url('/assets/fontello.ttf') format('truetype'), 
        url('/assets/fontello.svg#fontello') format('svg'); 
        font-weight: normal; 
        font-style: normal; 
    } 
    
  • 正如我所說,一切工作在發展細。我嘗試了很多東西。例如:

    1. 移動公共文件夾中的字體(如我的圖片有被加載)
    2. 添加以下行的assets.rb

      Rails.application.config.assets.precompile += [/^[-_a-zA-Z0-9]*\..*/] 
      

    ,但毫無效果。

    您能否建議其他方法嘗試?

    回答

    3

    ls public/assets輸出在生產中是什麼?

    也許你的文件有一個摘要(例如fontello-XXXX.ttf)。在這種情況下,你必須在你的sass中使用font helpers(不是css) - 例如。在您的字體家族區塊中:src:font-url('fontello.ttf')

    相關問題