一.踩坑
1.问题来源
- 如何自定义环境并在启动时指定环境
2.解决方案
- 使用configuration参数启动项目,如
ng serve --configuration=local or ng serve -c local
启动名为local的环境 - 环境的定义在angular.json文件中(architect下build和serve都要添加环境配置),如下所示
"configurations": {
"production": {
#定义环境名词
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true