如何修复 Angular 和 flag-icons:Two output files share the same path but have different contents: media/...svg

问题

你在 Angular 应用中使用 flag-icons 包,使用 ng buildng serve 构建应用时出现以下错误:

flag_icons_error.txt
[...]

✘ [ERROR] Two output files share the same path but have different contents: media/ic.svg

✘ [ERROR] Two output files share the same path but have different contents: media/un.svg


✘ [ERROR] Two output files share the same path but have different contents: media/xk.svg

解决方案

这仅影响开发构建,因为开发构建默认只有 outputHashing: "none"

因此,在 angular.json 中的开发构建选项中添加 outputHashing: "media"。如果你想哈希所有文件,也可以设置 outputHashing: "all",但我建议开发构建使用 outputHashing: "media"

这是你的 development 构建选项应该看起来的样子:

angular_development_config.json
  "development": {
    "optimization": false,
    "extractLicenses": false,
    "sourceMap": true,
    "outputHashing": "all"
  }

不要忘记在旧行末尾添加逗号。

原始来源flag-icons 的 GitHub 问题跟踪器


Check out similar posts by category: Angular