【问题标题】:How to set environment for Angular 7 in tfs build pipeline如何在 tfs 构建管道中为 Angular 7 设置环境
【发布时间】:2019-07-26 06:10:07
【问题描述】:

我试图在 tfs 构建管道中设置一个特定的环境,但它总是设置默认的开发环境。但是,ng serve 命令可以正常工作。

这是我的应用程序版本详细信息。

Angular CLI: 7.3.9
Node: 10.16.0
@angular-devkit/architect         0.13.9
@angular-devkit/build-angular     0.13.9
@angular-devkit/build-optimizer   0.13.9
@angular-devkit/build-webpack     0.13.9
@angular-devkit/core              7.3.9
@angular-devkit/schematics        7.3.9
@angular/cdk                      7.3.7
@angular/cli                      7.3.9

这是我的配置方式。

环境 >

└── environments
        ├── environment.prod.ts
        ├── environment.staging.ts
        └── environment.ts

angular.json

"configurations": {
  "production": { ... },
  "staging": {
    "fileReplacements": [
      {
        "replace": "src/environments/environment.ts",
        "with": "src/environments/environment.staging.ts"
      }
    ]
  }

angular.json > 服务

"serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "my-app:build"
          },
          "configurations": {
            "staging": {
              "browserTarget": "my-app:build:staging"
            },
            "production": {
              "browserTarget": "my-app:build:production"
            }
          }

构建管道脚本 >

我尝试运行不同的命令,但没有任何帮助。

build --prod --configuration=staging
build --prod --configuration staging
build --configuration=staging

【问题讨论】:

    标签: node.js angular typescript ecmascript-6 single-page-application


    【解决方案1】:

    在你的 package.json 中使用这个设置

    "scripts": {
        "stag": "ng build --configuration=staging",
      },
    

    然后在管道中使用npm run stag

    所以你的npm command 选项是run stag。无需争论

    【讨论】:

      【解决方案2】:

      在 package.json 中设置自定义构建命令后

      "scripts": {
      "staging": "ng build --configuration=staging",
      

      },

      在本地计算机中使用时使用 npm run staging,但在 azure build 中使用时使用 custome 命令和命令参数 run stagin

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2019-09-30
        • 1970-01-01
        • 1970-01-01
        • 2012-05-26
        • 1970-01-01
        • 2017-05-25
        • 2021-04-16
        相关资源
        最近更新 更多