I am willing to switch easily between production and development environments in an Ionic project. I have been following this guide : Environment Variables in Ionic and AngularJS
It is pretty straightforward, the gulp task will replace the variables with the values defined in the appropriate JSON file, which is chosen depending on the parameter passed to the task.
My issue here is that I do not call Gulp directly, but I call it through ionic CLI (ionic serve). I know that I can specify the gulp tasks to call in the ionic.project file, but how can I pass some parameters to the ionic CLI and have them piped to Gulp ?
I would like to simply do :
ionic serve --prod
ionic serve --dev --lab
And it would select the proper values for my constants accordingly to the parameter.
When you run ionic serve like so:
ENV=production ionic serve
in gulp to get ENV varaible
process.env.ENV
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With