Install font awesome 5 with npm for scss usage

前端 未结 4 1613
既然无缘
既然无缘 2021-02-05 12:03

like title says, I can not install font awesome 5 with npm for scss purposes.

Trying to install version 5

Accoring to https://fontawesome.com/how-to-use/use-wi

4条回答
  •  长发绾君心
    2021-02-05 12:06

    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

    
    

    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.

提交回复
热议问题