Rayjax
Rayjax

Reputation: 7784

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.

Upvotes: 6

Views: 839

Answers (1)

Uysim Ty
Uysim Ty

Reputation: 141

When you run ionic serve like so:

ENV=production ionic serve

in gulp to get ENV varaible

process.env.ENV

Upvotes: 7

Related Questions