Search code examples
font-awesomesingle-spa

How to setup font-awesome with a single-spa project?


I have a single spa application with a root-config, a styleguide, and a couple of react applications. All of these application are generated using the yarn create single-spa command.

I tried creating a kit from the font-awesome website and adding it to the root-config index.ejs inside the head tag.

Then I tried adding <i className='fa-brands fa-facebook-f' /> in one of my MFEs. The loaded index.html in my browser include the tag code. But it's dimensions are 0x0.


Solution

  • You are missing some styles.

    When you generate your kit, the font awesome website shares a snippet of the script tag for your kit. You need to place it in the head section of your root-config. But that's not all. You also need to add some font-faces.

    The same page (with the snippet) also has a link to download example html file. If you check that file it has extra style tags. Once you add those to your root-config, the icons will start showing up.

    This issue is not single-spa, it's the confusing documentation for font-awesome.