【发布时间】:2021-02-22 22:41:04
【问题描述】:
我为部署构建版本,需要为 prod、staging1 和 staging2 配置配置。 我在环境文件夹中有文件:
environments.ts
environments.prod.ts
environments.staging1.ts
environments.staging2.ts
在 Angular.json 我有部分:
"configurations": {
"prod": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"staging1": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.staging1.ts"
}
]
},
"staging2": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.staging2.ts"
}
]
}
当我像这样调用命令时:
call npm install
call npm run prod --configuration staging1
它仍然需要第一个环境文件:environment.prod.ts 文件,而不是 environment-staging1.ts
在 package.json 我有这样的构建命令:
{
"name": "finant",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "node start.js && ng serve",
"build": "node pre-build.js && ng build --configuration=prod --output-hashing=none --extra-webpack-config webpack.extra.js",
"prod": "npm run build && node build.js",
这是个问题,因为当我更改为 --configuration=staging1 时它可以工作,但我必须手动更改它
【问题讨论】: