Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass parameters to gulp task through ionic serve

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.

like image 970
Rayjax Avatar asked Aug 24 '15 09:08

Rayjax


Video Answer


1 Answers

When you run ionic serve like so:

ENV=production ionic serve

in gulp to get ENV varaible

process.env.ENV
like image 134
Uysim Ty Avatar answered Oct 19 '22 02:10

Uysim Ty