It seems after recently upgrading from angular 7 to angular 8 my app does not build properly with different environments.
For example i want to build using the test environment.
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"
}
]
}
}
},
However this doesen;'t work and reverts back to the default environment file.
environment.ts
export const environment = {
production: false,
build: 'Local',
...
};
environment.test.ts
export const environment = {
production: false,
build: 'Test',
...
};
npm run build --configuration=testshould be using angular cli's commandng build --configuration=test- penleychanpackage.jsonfile npm run build is the same as ng build. - Kayng build --configuration=test. The package.json contains preset of scripts, in your case forbuildisng build. Which means you can't just send additional args with out using--sonpm run build -- --configuration=testwould be the same asng build --configuration=test- penleychan