Automatically change constants between environments


I have an application that retrieves information from a website, I have a constant defined with the website url.

.constant(‘APP_CONSTANTS’, {
HOST: “”,
API: “

What I want is that when I am testing my application use, and when I publish my application use

Is there a way to archive this automatically? currently I have to change these constants every time I have to publish to the play store so.

Currently, I work with three different environnements :
I use an array with all three environnements in it and depending on where I want the build to be available, i just switch my environnement variable with the index of the array I want.
In order not to modify data in production, I use this array to modify the color of an element in my UI and then it feels a lot safer.

It’s a nice approach, but it stills requires that you remember to change the code each time you want to upload the app to the itunes or play store.

Yes, but in any case, you can’t really do this inside the app, because the user could see wrong data, unless you have a “hidden” service in your app that allows you to switch environnement.
For instance you could check a sequence of swipe events on a particular element that the user could never find.

↑ ↑ ↓ ↓ ← → ← → BA is a good one :wink: