gshigeto / ionic-environment-variables

Easy to use environment variables for Ionic3!
MIT License
276 stars 36 forks source link

How to run the app with custom environments? #2

Closed diegofsza closed 6 years ago

diegofsza commented 6 years ago

Hi, thank you for this approach. It worked perfectly.

However, It isn't clear to me how to run the app with a custom environment. Let´s suppose I have a custom configuration file called "environment.testing.ts", how would you start / build the app from command line with that configuration?

Thanks!

gshigeto commented 6 years ago

Sorry I haven't gotten back to you on this one! I just updated the README

If more than dev and prod environments are wanted, there are a few things you will need to do.

  1. Change your optimization.config.js and webpack.config.js IONIC_ENV variable to be something else. For example:
    './src/environments/environment' + (process.env.MY_ENV === 'prod' ? '' : '.' + process.env.MY_ENV) + '.ts'
  2. Add to your package.json another run script and name it whatever you would like
    "serve:testing": "MY_ENV=testing ionic-app-scripts serve"
  3. Create your testing file src/environments/environment.testing.ts. This should be whatever you set your MY_ENV to.
  4. Finally, run the script by using the name you used for your script in package.json
    $ npm run serve:testing
sapnagroup commented 6 years ago

How do I run it for android and ios build?