ng-cli 6 and font awesome icons not working

这一生的挚爱 提交于 2019-12-04 08:25:31

I also went through this problem and decided as follows. In the angular.json file in the build > assets section I included the path of the fonts to be copied:

{
     "glob": "**/*",
     "input": "node_modules/font-awesome/fonts",
     "output": "assets/fonts"
}

And in the build > styles section I've included the font-awesome path in the node_modules folder:

{
    "input": "node_modules/font-awesome/scss/font-awesome.scss"
}

And finally, in the global scss-style file I've included these instructions:

$fa-font-path: "../assets/fonts" !default;
i[class^="fa-"], ion-icon[class^="fa-"] {
    font-family: "FontAwesome" !important;
}

Note that in the global scss-style file I also include the ion-icon, in case you are using Ionic.

I hope this solves your problem.

First, install font awesome

npm install font-awesome

and then add

@import "~font-awesome/css/font-awesome.css;

in the styles.css file.

Yangyi Li

click font-awesome/fonts/fontawesome-webfont.ttf or font-awesome/fonts/FontAwesome.otf file and install the FontAwesome font in your OS

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!