问题描述
您是否必须eject
您的angular-cli并覆盖Webpack配置,以便将font-awesome
字体放入资产/字体文件夹中?我有这个angular-cli,并且在我的angular-cli.json
中以这种方式包括了font-awesome:
Do you have to eject
your angular-cli and override the webpack configuration in order to place the font-awesome
fonts into the assets/fonts folder? I have this angular-cli and I include the font-awesome this way in my angular-cli.json
:
"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所在的位置)中.
but when I do ng build --prod
I get everything built correctly however all font-awesome fonts are located in the root (where the styles.css is).
您是否可以通过angular-cli.json进行配置,还是必须通过在packages.json中编写脚本来做到这一点?
Can you configure this through angular-cli.json or do you have to do it via scripting in the packages.json?
在Wiki上进行资产管理( https://github .com/angular/angular-cli/wiki/stories-asset-configuration ),我尝试过:
Looking at the wiki for assets management (https://github.com/angular/angular-cli/wiki/stories-asset-configuration), I tried this:
"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
Looks like is not possible? --> https://github.com/angular/angular-cli/issues/6637
推荐答案
我认为您只是遵循 http://github.com/angular/angular-cli/blob/master/docs/documentation/stories/include-font-awesome.md 在ng serve/build
期间,一旦看到您引用font-awesome
,它只是将字体文件复制到根目录中.
I think you just followed http://github.com/angular/angular-cli/blob/master/docs/documentation/stories/include-font-awesome.md during ng serve/build
once cli seeing you referencing the font-awesome
it is just copying the fonts files like it is in to the root.
似乎是类似的问题如何在用angular4编译时如何将所有字形放置到一个文件夹中? angular cli只是以这种方式处理font-awesome.css
引用的字体,所以它只会影响客户端浏览器的output/dist
文件夹不在乎,所以应该不会受伤.
Seems like it is similar issue How can i place all the glyphicons to one folder while building in angular4? angular cli just handling the fonts referenced by font-awesome.css
this way so it is just affecting the output/dist
folder that client browser does not care about so it is should not hurt.
这篇关于Angular CLI将真棒字体文件输出到dist根目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!