【问题标题】:Angular CLI outputs the font-awesome font files the dist rootAngular CLI 将字体很棒的字体文件输出到 dist 根目录
【发布时间】:2018-03-17 00:40:19
【问题描述】:

您是否必须 eject 您的 angular-cli 并覆盖 webpack 配置才能将 font-awesome 字体放入 assets/fonts 文件夹中?我有这个 angular-cli,并以这种方式在我的angular-cli.json 中包含了 font-awesome:

"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

【问题讨论】:

  • 可能在webpack中配置

标签: angular angular-cli font-awesome webpack-2


【解决方案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 文件夹,所以它不应该受到伤害。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-06-26
    • 2020-08-02
    • 2021-07-25
    • 2021-04-20
    • 1970-01-01
    • 2020-05-28
    • 2017-06-25
    相关资源
    最近更新 更多