如何修复 'ng build' 不使用 @angular/localize 构建本地化版本
问题
你使用 @angular/localize 来本地化你的 Angular 应用,但 ng build 不构建本地化版本。换句话说,dist/myapp/index.html 存在,但 dist/myapp/en/index.html 不存在。
解决方案
你需要在 angular.json 中的构建选项中添加 localize: true。
摘录:
locales.json
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:application",
"options": {
"localize": true
}
}
}通常,architect/build/options 已经存在,所以你只需要添加 localize: true 行。
不要忘记在旧行末尾添加逗号。
进行此更改后,ng build 将构建你的应用的本地化版本。
Check out similar posts by category:
Angular
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow