打开 angular.json -> projects -> 项目名 -> architect -> build -> configurations -> production
。复制该配置以设置更多的配置项
更改对应的配置文件路径
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
分别执行: ng s -c=dev
与 ng s -c=prod
与 ng s
,会看到不同的结果:dev
, prod
, test
。
在发布时,需要将命令稍作修改: ng build --prod -c=prod