tomkra / font_awesome5_rails

font_awesome_5_rails is font awesome 5 gem bundled for rails asset pipeline
https://fontawesome.com/
MIT License
158 stars 25 forks source link

Add instructions for Rails 7 with Propshaft and CSS Bundling #70

Closed abevoelker closed 2 years ago

abevoelker commented 2 years ago

I upgraded a Rails app from 6.1 to 7 and to the new Propshaft + CSS Bundling setup and this is the process I followed to get the fa_icon helpers working again. I don't know if this is the ideal method but after a little tinkering it's what I came up with that works.

abevoelker commented 2 years ago

Another approach instead of copying the fonts over to app/assets would be to add the node_modules folder to the Propshaft load path:

# config/initializers/assets.rb
Rails.application.config.assets.paths << Rails.root.join("node_modules/@fortawesome/fontawesome-free")

However that would also make the other files in that directory visible to Propshaft:

$ ls -F node_modules/@fortawesome/fontawesome-free
css/  less/      scss/     svgs/      attribution.js  package.json
js/   metadata/  sprites/  webfonts/  LICENSE.txt
tomkra commented 2 years ago

Thank you for your work @abevoelker . Personally I didn't already upgraded my projects to rails 7, so I'm glad you've figured it out.

abevoelker commented 2 years ago

Any time, thanks for the gem! :tada: