Using webpack and scss:
Install font-awesome using npm (using installation instructions at https://fontawesome.com/how-to-use )
npm install @fortawesome/fontawesome-free
Next, using the copy-webpack-plugin, copy the WebFonts folder from node_modules to the Dist folder during the WebPack build process. ( https://github.com/webpack-contrib/copy-webpack-plugin )
npm install copy-webpack-plugin
In the webpack.config.js file, configure copy-webpack-plugin . NOTE. By default, the webpack 4 dist folder is the dist folder, so we copy the webfonts folder from node_modules to the dist folder.
const CopyWebpackPlugin = require('copy-webpack-plugin'); module.exports = { plugins: [ new CopyWebpackPlugin([ { from: './node_modules/@fortawesome/fontawesome-free/webfonts', to: './webfonts'} ]) ] }
Finally, in your main.scss file , tell fontawesome where the webfonts folder was copied , and import the necessary SCSS files from node_modules .
$fa-font-path: "/webfonts"; @import "../node_modules/@fortawesome/fontawesome-free/scss/fontawesome"; //Include at least one of the below, depending on what icons you want. @import "../node_modules/@fortawesome/fontawesome-free/scss/brands"; @import "../node_modules/@fortawesome/fontawesome-free/scss/regular"; @import "../node_modules/@fortawesome/fontawesome-free/scss/solid"; @import "../node_modules/@fortawesome/fontawesome-free/scss/v4-shims";
pppglowacki 02 Oct '18 at 13:29 2018-10-02 13:29
source share