在从最近的角度7升级到角度8之后,我的应用似乎无法在不同的环境下正常构建。
例如,我想使用测试环境进行构建。
npm run build --configuration=test
angular.json
"configurations": {
"production": {
"index": "src/production/index.html",
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
},
"test": {
"index": "src/test/index.html",
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.test.ts"
}
]
}
}
},
但这确实不起作用;并且无法恢复到默认环境文件。
environment.ts
export const environment = {
production: false,
build: 'Local',
...
};
environment.test.ts
export const environment = {
production: false,
build: 'Test',
...
};
答案 0 :(得分:0)
ng build --configuration=test
应该可以工作。我们使用相同的设置。
考虑angular.json
中的输出路径(在以下位置:项目>您的项目>架构师>构建>选项> outputPath)。