Angular CLI输出dist root的字体真棒字体文件

时间:2017-10-05 11:48:59

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

您是否必须eject您的angular-cli并覆盖webpack配置才能将font-awesome字体放入assets / fonts文件夹中?我有这个angular-cli,我在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所在的位置)。

你可以通过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 个答案:

答案 0 :(得分:0)

我认为您在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文件夹所以它不应该受伤。