like title says, I can not install font awesome 5 with npm for scss purposes.
Accoring to https://fontawesome.com/how-to-use/use-with-node-js
npm i --save @fortawesome/fontawesome
Looking through the installation in node_modules I see no scss file to hook up to. I tried including the styles.css file in my app.scss file but that did not work.
package.json
"font-awesome": "^4.7.0",
app.scss
@import "node_modules/font-awesome/scss/font-awesome.scss";
Usage
<i className="fa fa-save icon controlItem"></i>
Easy as pie. How can I achieve this with version 5?? Am I using the wrong package?
Apparently, just using @fortawesome/fontawesome is not eanough. The packages have been split up so you also have to select
npm install --save @fortawesome/fontawesome-free-regular
Still I have no success importing it
Adding Font Awesome to Your CompileOpen your project's scss/variables. scss and edit the $fa-font-path variable to point to where you placed the webfonts folder. $fa-font-path: "../webfonts"; In your main SCSS compile file, import Font Awesome by adding the core styles file, @import "scss/fontawesome.
OR you can import the module in your js code. import '@fortawesome/fontawesome-free/js/all. js'; OR if you are using Sass, you can import the module in app.
Install font-awesome using npm. This is the most maintainable way as npm update will refresh the dependencies for you. Adjust your paths to account for where scss file is located in your project: You can also use a shorter syntax using tilda (~) prefix:
- GeeksforGeeks How to load font-awesome using SCSS ? In order to load font-awesome icons in SCSS you need to follow these steps: Install Font-Awesome starter kit: Go to the font-awesome website and download the free starter-kit for web. The public folder will contain your html and css files whereas the resources folder contains your scss files.
Install Font-Awesome starter kit: Go to the font-awesome website and download the free starter-kit for web. The public folder will contain your html and css files whereas the resources folder contains your scss files.
Font Awesome has an official Angular component. npm install --save @fortawesome/fontawesome-svg-core npm install --save @fortawesome/free-<type>-svg-icons npm install --save @fortawesome/angular-fontawesome Note: Replace <type> with solid, brands or regular whatever type of icons you need. You can also install Vue and React components.
npm install --save-dev @fortawesome/fontawesome
npm install --save-dev @fortawesome/free-regular-svg-icons
npm install --save-dev @fortawesome/free-solid-svg-icons
npm install --save-dev @fortawesome/free-brands-svg-icons
In your app.js
or equivalent Javascript file,
import fontawesome from '@fortawesome/fontawesome'
import regular from '@fortawesome/free-regular-svg-icons'
import solid from '@fortawesome/free-solid-svg-icons'
import brands from '@fortawesome/free-brands-svg-icons'
fontawesome.library.add(regular)
fontawesome.library.add(solid)
fontawesome.library.add(brands)
For usage, there are slight changes to the way the class names are being used. Please refer to the icons on Fontawesome site for the "full" class names.
Example
<i class="fas fa-chevron-left"></i>
Although the idea of adding all the 3 variants of fonts into the project seems to be a convenient thing, do beware that this will slow performance when building/compiling your project. Thus, it is highly recommended that you add the fonts you need instead of everything.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With