In my web app built on Laravel, which under the hood uses an npm/Webpack build process, I'm currently using the SCSS icon sheet versions of FontAwesome like this:
@import '~@fortawesome/fontawesome-free/scss/fontawesome';
@import '~@fortawesome/fontawesome-free/scss/solid';
@import '~@fortawesome/fontawesome-free/scss/brands';
This is more lightweight than the default setup of loading every single FontAwesome icon, but still results in loading thousands of icons when I'm using less than 20 throughout the whole project.
I therefore want to move to importing individual icons, as documented here.
I uninstalled the old package and installed those that seem to be required by the link above:
npm uninstall @fortawesome/fontawesome-free
npm install --save @fortawesome/fontawesome-svg-core
npm install --save @fortawesome/free-solid-svg-icons
I added the following to my project's bootstrap.js (where all the other external imports live):
import { library } from "@fortawesome/fontawesome-svg-core";
import { faMugHot } from "@fortawesome/free-solid-svg-icons";
import { faBolt } from "@fortawesome/free-solid-svg-icons";
library.add(faMugHot, faBolt);
And finally ran npm run dev to rebuild the JS, but both of the two example icons that I'm loading fail to display.
I'm referencing the icons in my markup like so:
<i class="fas fa-mug-hot"></i>
<i class="fas fa-bolt"></i>
I've also tried enabling the options that are disabled by default when using the SVG Core package:
import { config } from "@fortawesome/fontawesome-svg-core";
config.autoReplaceSvg = true;
config.observeMutations = true;
import { library } from "@fortawesome/fontawesome-svg-core";
import { faMugHot } from "@fortawesome/free-solid-svg-icons";
import { faBolt } from "@fortawesome/free-solid-svg-icons";
library.add(faMugHot, faBolt);
...but this doesn't make the icons load either.
This seems to be the method suggested by the documentation here, so why isn't it working for me? What am I doing wrong here?