由于您使用的是 Angular 6,因此您可以根据需要调整 angular.json。
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",<--none
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,<---false
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true
}
}
},
或者,您可以修改 package.json 中现有的构建脚本
"scripts": {
"ng": "ng",
"start": "ng serve --prod",
"build": "ng build --prod --aot=false --output-hashing none",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
执行npm run-script build或npm run build