Angular Project Production版本在导入Google字体时遇到问题

时间:2019-10-17 12:49:42

标签: angular angular-material google-fonts

我有一个基于最新版本8.2.9的角度项目。在使用ng serve的测试环境中,Google字体可以完美运行。但是,当我在生产服务器上发布项目时,不会加载字体。

style.scss

@import url('https://fonts.googleapis.com/css?family=Nunito:200,600');
@import url('https://fonts.googleapis.com/icon?family=Material+Icons');

由于上述问题,材料图标未如图中所示加载。enter image description here

但是,当我将上述字体加载语句从全局样式style.scss移到app.component.scss时。工作正常!它为何无法采用全球风格?我在这里ng build/serve --prod ignores scss url imports

找到了与此问题类似的东西

1 个答案:

答案 0 :(得分:0)

只需在<head>标签中将Google字体包含在index.html中,而不是任何scss或css文件中即可。

它也可以用于生产版本。

http://prntscr.com/qx71rf

相关问题