I just made it work but I’m not entirely sure why it works so I would appreciate any insight or improvements on this solution. In the meantime, I’m happy to share with the world:
First, you need to pin the Font Awesome Javascript packages by running:
pin "@fortawesome/fontawesome-free", to: "https://ga.jspm.io/npm:@fortawesome/fontawesome-free@6.0.0/js/fontawesome.js"
pin "@fortawesome/fontawesome-svg-core", to: "https://ga.jspm.io/npm:@fortawesome/fontawesome-svg-core@1.3.0/index.es.js"
pin "@fortawesome/free-brands-svg-icons", to: "https://ga.jspm.io/npm:@fortawesome/free-brands-svg-icons@6.0.0/index.es.js"
pin "@fortawesome/free-regular-svg-icons", to: "https://ga.jspm.io/npm:@fortawesome/free-regular-svg-icons@6.0.0/index.es.js"
pin "@fortawesome/free-solid-svg-icons", to: "https://ga.jspm.io/npm:@fortawesome/free-solid-svg-icons@6.0.0/index.es.js"
to your importmap.rb.
Then in your app/javascript/application.js you need to add:
import {far} from "@fortawesome/free-regular-svg-icons"
import {fas} from "@fortawesome/free-solid-svg-icons"
import {fab} from "@fortawesome/free-brands-svg-icons"
import {library} from "@fortawesome/fontawesome-svg-core"
import "@fortawesome/fontawesome-free"
library.add(far, fas, fab)
If you don’t need one of the libraries you can skip them, but skipping the last two imports or adding each icon package to the library makes it not work.
In my experience, the icons show up with a slight delay, when I use the npm package.
When I put gem "font-awesome-sass", "~> 6.1.1" in my Gemfile (link to gem) and do bundle install, all icons loads fast. (And you don’t need to use SCSS, you can call the icons with the standard HTML tag.)