How to make Font awesome 5 work with webpack

前端 未结 7 1795
野性不改
野性不改 2021-01-30 16:33

I\'m trying to use Fontawesome in my Flask/webpack project.

The craziest thing is some point it worked then stopped, I changed something stupid, it worked again and fina

7条回答
  •  你的背包
    2021-01-30 17:13

    First install the following,

    npm install file-loader @fortawesome/fontawesome-free --save
    

    And then in the webpack.config.js, Add

    { test: /\.(woff|woff2|eot|ttf|otf)$/,
      loader: 'file-loader',
      options: {
        outputPath: '../fonts',
    }
    

    Finally,

    $fa-font-path: '../node_modules/@fortawesome/fontawesome-free/webfonts'; 
    @import '../node_modules/@fortawesome/fontawesome-free/scss/fontawesome';
    @import '../node_modules/@fortawesome/fontawesome-free/scss/solid';
    @import '../node_modules/@fortawesome/fontawesome-free/scss/regular';
    

    This should do the trick

提交回复
热议问题