How do I load font-awesome using SCSS (SASS) in Webpack using relative paths?

前端 未结 9 2173
有刺的猬
有刺的猬 2020-12-07 16:20

I have font-awesome in my node_modules folder so I try to import it in my main .scss file like so:

@import \"../../node_modules/font-awesome/scss/font-awesom         


        
相关标签:
9条回答
  • 2020-12-07 16:56

    This is how it worked for me, the trick is to set $fa-font-path to the path of the fonts as following.

    $fa-font-path: "~@fortawesome/fontawesome-free/webfonts/";
    @import '~@fortawesome/fontawesome-free/scss/fontawesome.scss';
    @import '~@fortawesome/fontawesome-free/scss/solid.scss';
    @import '~@fortawesome/fontawesome-free/scss/brands.scss';
    

    Note: Please check your fonts folder in node_modules in my case it is @fortawesome/fontawesome-free

    0 讨论(0)
  • 2020-12-07 16:59

    v.4 (symofony 4 + webpack)

    $fa-font-path: "~components-font-awesome/webfonts";
    @import '~components-font-awesome/scss/fa-brands';
    @import '~components-font-awesome/scss/fa-regular';
    @import '~components-font-awesome/scss/fa-solid';
    @import '~components-font-awesome/scss/fontawesome';
    
    0 讨论(0)
  • 2020-12-07 17:04

    For Version 5.14, the following worked for me:

    $fa-font-path : '../node_modules/@fortawesome/fontawesome-free/webfonts';
    
    @import "../node_modules/@fortawesome/fontawesome-free/scss/solid";
    
    @import "../node_modules/@fortawesome/fontawesome-free/scss/brands";
    
    @import "../node_modules/@fortawesome/fontawesome-free/scss/fontawesome";
    
    0 讨论(0)
提交回复
热议问题