1. console:
yarn add @fortawesome/fontawesome-free
2. javascript/packs/application.js:
import "@fortawesome/fontawesome-free/css/all"
3. Check if it works:
Add couple of icons in any .html.erb (view) file:
<i class="far fa-address-book"></i>
<i class="fab fa-github"></i>
That’s it!😊
Top comments (9)
How did you find out what to import? How did you know that it was "@fortawesome/fontawesome-free/css/all"?
Is there like a strategy or guide? Sometimes, I want to add something with yarn but I don't know what to import.
Thanks!
Once you install node packages using yarn or npm, it will download the package and store it directly inside node_modules directory in your current working directory.
so in this case, the package is stored in /node_modules/@fortawesome/fontawesome-free/css/all.[css|scss]
hope it help
In step 2, change
css
tojs
to get the icons working in production mode.Thank you very much for this advice.
Without webpacker, with Rails 7 and css/jsbundling-rails with esbuild, I had to put
@import "@fortawesome/fontawesome-free/css/all";
insideassets/stylesheets/application.scss
.That's simple and awesome! Thanx a lot!
Thanks! Works perfectly.
Interesting. I followed this, and some of my FA icons disappeared. For example, fa-globe still shows, but fa-wordpress doesn't.
В очередной раз, спасибо большое )