angular8 配置 测试环境打包指令 生成测试环境包指令

时间:2019-09-26
本文章向大家介绍angular8 配置 测试环境打包指令 生成测试环境包指令,主要包括angular8 配置 测试环境打包指令 生成测试环境包指令使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

1.angular.json 文件中在architect 下添加 buildTest指令

距离位置

projects => (你的项目名称) => architect 下
和 build 指令 serve 指令同级
    "buildTest": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/insuranceTest/",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.app.json",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.less"
            ],
            "scripts": []
          },
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "2mb",
                  "maximumError": "5mb"
                }
              ]
            }
          }
        },    

  

2.配置测试环境打包指令

打开package.json文件

在script中添加

"buildTest": "ng run biService:buildTest --build--optimizer --aot ",

 

3.使用

npm run buildTest

这时候就会执行测试环境的打包指令 并且会在 dist/insuranceTest 路径下生成测试环境的包文件

原文地址:https://www.cnblogs.com/MainActivity/p/11589401.html