Font Awesome 5 and Angular 5

Valentine picture Valentine · Jul 5, 2018 · Viewed 9.6k times · Source

I was using font-awesome npm package (which is Font Awesome 4.7 version) but I want to upgrade to Font Awesome 5. I've install the following packages :

"@fortawesome/angular-fontawesome": "^0.1.1",
"@fortawesome/fontawesome": "^1.1.8",
"@fortawesome/fontawesome-free-brands": "^5.0.13",
"@fortawesome/fontawesome-free-regular": "^5.0.13",
"@fortawesome/fontawesome-free-solid": "^5.0.13",
"@fortawesome/fontawesome-svg-core": "^1.2.0",
"@fortawesome/free-solid-svg-icons": "^5.1.0",

I was using icons like this :

<i class="fa fa-plus"></i>

With the new version I tried to use icons like this :

<i class="fas fa-sign-out-alt fa-2x"></i>

But this is not working. I try to add icons like this :

import {faSignOutAlt} from '@fortawesome/fontawesome-free-solid';
import fontawesome from '@fortawesome/fontawesome';
fontawesome.library.add(faSignOutAlt);

in my app.module.ts and it is working, but I don't want to import each icon one by one. Is there a way to use them like I was doing with the previous version ? Eather a way to not import them one by one ?

Thanks

Answer

Diego Salguero picture Diego Salguero · Sep 6, 2018

Install

npm install --save @fortawesome/fontawesome-free

and use in .angular-cli

 "styles": [
    "styles.css",
    "../node_modules/@fortawesome/fontawesome-free/css/all.css",

reference : Using a Package Manager