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 路径下生成测试环境的包文件