Angular CLI将真棒字体文件输出到dist根目录 [英] Angular CLI outputs the font-awesome font files the dist root

查看:155
本文介绍了Angular CLI将真棒字体文件输出到dist根目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您是否必须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

推荐答案

我认为您只是遵循

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.

似乎是类似的问题

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根目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆