We have multiple environments, and we have environment files which having backend configarations and we are using these files during the builds.
Example: ng build –c UAT
But I have a issue here, now we decided to build only once and deployment multiple environments same artifact.
I know this is quite achievable using an Angular service and the APP_INITIALIZER token, but some reason we can’t use this.
So I decided to after the build, modify the compiled js files(main.js) with respective env configuration values. But it’s becoming difficult because of increased number of env variable and its patterns.
So I thought of follow below process, please suggest it can usable or i should not
1, I’ll build UAT webpack(dist/artifact) using the "ng build –c UAT".
2, I’ll do same for all other environments, now I have total 3 dist folders(webpacks).
3, I’ll deploy the UAT artifact to all environment s, but before deploying it to Preprod I’ll replace "main.js" file with Preprod artifact main.js file because only main.js file have the all environment configarations. and keep all other js files same.
4, I’ll repeat same with prod deployment.
Please suggest on this approach.
Source: AngularJS Questions