Angular 多阶段的角度环境

Angular 多阶段的角度环境,angular,npm,Angular,Npm,我为部署构建版本,需要为prod、staging1和staging2进行配置。 我在环境文件夹中有文件: environments.ts environments.prod.ts environments.staging1.ts environments.staging2.ts 在Angular.json中,我有以下部分: "configurations": { "prod": { "file

我为部署构建版本,需要为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
{
  "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",
它仍然需要第一个环境文件:
environment.prod.ts
文件,而不是
environment-staging1.ts


在package.json中,我有如下构建命令:

call npm install
call npm run prod --configuration staging1
{
  "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时,它可以工作,但我必须手动更改它才能工作,您需要使用double
--

npm运行产品---配置阶段1

我在postAbove命令中添加的注释无效,因为它仍然使用
--configuration=prod