How to add Fontawesome 5 to Symfony 4 using Webpack Encore

后端 未结 7 1620
鱼传尺愫
鱼传尺愫 2020-12-29 04:34

I want to add Font Awesome 5 to my Symfony 4 project, this is what I did :

  • I added font awesome to my project using yarn : yarn add --dev @fortawesome/f
7条回答
  •  一个人的身影
    2020-12-29 05:23

    The following as above works perfectly for me:

    npm install @fortawesome/fontawesome-free @fortawesome/free-brands-svg-icons @fortawesome/free-regular-svg-icons @fortawesome/free-solid-svg-icons -D
    

    Add the following into a .scss file

    @import '~@fortawesome/fontawesome-free/scss/fontawesome';
    @import '~@fortawesome/fontawesome-free/scss/regular';
    @import '~@fortawesome/fontawesome-free/scss/solid';
    @import '~@fortawesome/fontawesome-free/scss/brands';
    

    works with webpack 4

    {
        test: /\.woff2?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
        use: 'url-loader?limit=10000',
    },
    {
        test: /\.(ttf|eot|svg)(\?[\s\S]+)?$/,
        use: 'file-loader',
    },
    {
        test: /\.(jpe?g|png|gif|svg)$/i,
        use: [
            'file-loader?name=images/[name].[ext]',
            'image-webpack-loader?bypassOnDebug'
        ]
    }]
    

提交回复
热议问题