bokmann / font-awesome-rails

the font-awesome font bundled as an asset for the rails asset pipeline
http://fortawesome.github.com/Font-Awesome/
MIT License
1.86k stars 244 forks source link

Not precompiling fonts in production #200

Open crissmancd opened 6 years ago

crissmancd commented 6 years ago

It appears that the font files are not being precompiled in production. The css files work, but fonts are not found. These are the rails/sass gems installed:

* autoprefixer-rails (7.1.6)
* bootstrap-sass (3.3.7)
* coffee-rails (4.2.2)
* dotenv-rails (1.0.2)
* factory_girl_rails (4.9.0)
* font-awesome-rails (4.7.0.4)
* jquery-rails (4.3.1)
* pry-rails (0.3.6)
* rails (5.1.4)
* rails-controller-testing (1.0.2)
* rails-dom-testing (2.0.3)
* rails-html-sanitizer (1.0.4)
* rspec-rails (3.7.2)
* sass (3.5.3)
* sass-listen (4.0.0)
* sass-rails (6.0.0.beta1 dd04a6a)
* sprockets-rails (3.2.1 857e781)

I've added this to assets.rb: Rails.application.config.assets.precompile += %w( *.tt *woff *.woff2 *.svg *.eot )

Does anything need to be added to the assets manifest file? Not sure what I'm missing here.

koreymacdougall commented 6 years ago

edit: I thought we were having the same problem, but now I'm not sure. The fonts are precompiling for me, but they're compiling with the wrong paths, and so the app isn't finding them. Inspecting the http requests shows the app looking for the assets at a path with an additional asset prefix prepended for me. If you see in your traffic inspector that this isn't happening for you, disregard my comments below.


I was/am having the same problem. Still working on the proper rails solution, but I was able to hot-fix my app by making the following modifications to font-awesome-rails-4.7.0.4/app/assets/stylesheets/font-awesome.css.erb (removing use of font_path, essentially):

 src: url('<%= font_path('fontawesome-webfont.eot') %>');
 src: url('<%= font_path('fontawesome-webfont.eot') %>?#iefix') format('embedded-opentype'), url('<%= font_path('fontawesome-web    font.woff2') %>') format('woff2'), url('<%= font_path('fontawesome-webfont.woff') %>') format('woff'), url('<%= font_path('fontaweso    me-webfont.ttf') %>') format('truetype'), url('<%= font_path('fontawesome-webfont.svg') %>#fontawesomeregular') format('svg');  

becomes:


 src: url('<%= 'fontawesome-webfont.eot' %>');
 src: url('<%= 'fontawesome-webfont.eot' %>?#iefix') format('embedded-opentype'), url('<%= 'fontawesome-webfont.woff2' %>') format(    'woff2'), url('<%= 'fontawesome-webfont.woff' %>') format('woff'), url('<%= 'fontawesome-webfont.ttf' %>') format('truetype'), url('    <%= 'fontawesome-webfont.svg' %>#fontawesomeregular') format('svg');$

Hope this is of some help.

I'm looking into the use of the font_path variable to avoiding needing to modify the gem code, and will post the solution if I find it.

iarobinson commented 5 years ago

We experienced this issue too. I've documented it elsewhere. Please let me know if you're interested in having me put the screenshots describing the problem here.

In the end, we decided to remove this gem and use the Font Awesome CDN.

elduglas commented 5 years ago

My solution was download font awesome 4.7 and copy/paste the css and font files.