您是否必须 eject
您的angular-cli并覆盖webpack配置才能将 font-awesome
字体放入assets / fonts文件夹中?我有这个angular-cli,我在_1096663中以这种方式包含了字体 - 真棒:
"styles": [
"styles.css",
"../node_modules/bootstrap/dist/css/bootstrap.min.css",
"../node_modules/font-awesome/css/font-awesome.min.css"
],
但是当我做 ng build --prod
时,我得到了所有正确构建的内容,但是所有字体真棒字体都位于根目录中(styles.css所在的位置) .
你能通过angular-cli.json配置它吗?或者你必须通过packages.json中的脚本来完成它吗?
看一下wiki的资产管理(https://github.com/angular/angular-cli/wiki/stories-asset-configuration),我试过这个:
"assets": [
{ "glob": "**/*", "input": "./assets/", "output": "./assets/" },
{ "glob": "favicon.ico", "input": "./", "output": "./" },
{ "glob": "**/*", "input": "../node_modules/font-awesome/fonts/*", "output": "./assets/fonts/" }
]
但那没用 .
更新:
看起来不可能吗? - > https://github.com/angular/angular-cli/issues/6637
1 回答
我认为你在
ng serve/build
期间只是跟着http://github.com/angular/angular-cli/blob/master/docs/documentation/stories/include-font-awesome.md,一旦cli看到你引用font-awesome
它只是将字体文件复制到根目录中 .好像它是类似的问题How can i place all the glyphicons to one folder while building in angular4? angular cli只是处理
font-awesome.css
引用的字体这样,所以它只是影响客户端浏览器不关心的output/dist
文件夹所以它不应该受到伤害 .