在Angular 7应用程序上,我具有以下environment.prod.ts
文件:
export const environment = {
production: true,
apiBaseUri: 'https://api.xyz.com'
};
我需要在2台不同的计算机上发布该应用程序。
我每个都需要两个配置:生产和登台。
所以我需要类似以下环境文件的内容:
environment.prod.machine-1.ts
environment.prod.machine-2.ts
environment.staging.machine-1.ts
environment.staging.machine-2.ts
我应该如何定义这些环境文件?
以及如何构建应用程序?
答案 0 :(得分:1)
在angular.json
的{{1}}下,您可以定义每台计算机的每种配置类型。在每个配置下,定义"projects.<your project name>.architect.build.configurations"
,如下所示:
fileReplacements
然后,要使用该环境构建项目,请运行
"projects": {
"<your project name>": {
"architect": {
"build": {
"configurations": {
"machine-1.production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.machine-1.ts"
}
]
},
"machine-1.staging": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.staging.machine-1.ts"
}
]
},
// same for machine 2, etc...
}
}
}
}
}
(或您想要的任何其他环境)。