Home > Enterprise >  How to add font awesome to rails 7 (jsbundling)?
How to add font awesome to rails 7 (jsbundling)?

Time:11-09

Sorry this topic has been covered many times. However, I just created a new rails 7 app using esbuild, added font-awesome-sass to the gem file, created application.css.scss (already had application.bootstrap.scss) and put "@import 'font-awesome';" in there.

I then added the following to a view page:

      <i ></i>
      <%= icon 'fa-brands', 'font-awesome' %>

No page errors, no console errors---but, the icons are not visible on the page (code is in the source). I've been mindlessly trying to figure this out---but, can not figure out why this is not working.

Have I missed any step?

I've verified installation instructions for the gem, I also tried skipping the gem and installing fontawesome via yarn. Nothing has gotten icons to show up in the view.

CodePudding user response:

I have just tried with this and everything is fine, Could you try it?

CodePudding user response:

As are you using esbuild, you can install fontawesome with npm

yarn add @fortawesome/fontawesome-free

and import it in your javascript/application.js

import "@fortawesome/fontawesome-free/js/all";

Just remember to use only the free icons, fa-sharp is not free

  • Related