Spa
Spa

Reputation: 531

Font-Awesome in Rails 5 not getting precompiled

we recently updated from Rails 4.2.7 to Rails 5 and now we are having an issue with Font-Awesome when we precompile the assets.

We include the font-awesome-rails gem (v4.7.0.0) and everything works fine in development. But if we run rails assets:precompile (it doesn't matter if in dev or production env) the fonts are not appearing in public/assets.

Our manifest.js looks like this:

# app/assets/config/manifest.js

//= link_directory ../javascripts .js
//= link_directory ../stylesheets .css
//= link emails/base.css
//= link_tree ../images
//= link_tree ../fonts

Our assets.rb is the default one, as you config it now in the manifest.js

# Be sure to restart your server when you modify this file.

# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '2.0'

# Add additional assets to the asset load path
# Rails.application.config.assets.paths << Emoji.images_path

# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# Rails.application.config.assets.precompile += %w( search.js )

We are using sass in our Application with the sass-rails gem from master

Does anyone have an idea what is the problem here?

Regards,
spa

Upvotes: 1

Views: 1988

Answers (2)

Daniel Lin
Daniel Lin

Reputation: 1

Just put fonts under app/assets/fonts , and modify url('Your Font Path') to font-url('Your Font Path') in your scss. Asset Pipeline will auto precompile fonts into public/assests folder.

Upvotes: 0

Spa
Spa

Reputation: 531

Found the solution.
If I add

%w(eot svg ttf woff woff2).each do |ext|
  Rails.application.config.assets.precompile << "fontawesome-webfont.#{ext}"
end

to the assets.rb initializer, everything works fine.
I thought you skip that part, as you should just use the new manifest.js now.

Again what learned.

Upvotes: 4

Related Questions