Change constants depending on enviroment


#1

Hi,

I have several backend services in my project that use different URLs depending on which environment I build for (develop, production, demo, etc).

Until now, I change this values depending on enviroment with Gulp script, but migranting to RC0, there are a step “Delete the gulpfile.js”.

My question is, How to do that in Ionic 2? In this RC, were added two files, main.dev.ts and main.prod.ts. In the new releases there are nothing about this files, but in the Ionic 2 Conference Application they were removed. There is just a file called main.ts.

What can I do? This is a bug?


#2

I use a modified version of a cordova hook presented here:

http://www.kdmooreconsulting.com/blogs/build-a-cordova-hook-to-setup-environment-specific-constants/

Basically I have a config folder that has a “config.dev.json”, “config.qa.json”, etc. During the build process I execute:

“config_target=qa ionic build ios”

The hook will pull in the correct environment specific json file to the assets/api folder using the name “config.json”. I have a provider that loads the the config.json and then I inject that into other components that may needed it. Working good so far until we have an official solution from the ionic team.


#3

It’s worked, thanks.

I realy expect a better and native solution from Ionic Team.