Replace variables in config.xml during build

I’m using ionic v2 and setting plugins using ionic state reset (plugins are in cordovaPlugins in package.json). I’m using the cordova-plugin-fabric which has some required variables. I don’t want these hard coded in my config.xml – I want them to be set from environment variables at build time. I’m open to a variety of solutions, but I can’t get ionic state reset --variable to work. I’m also trying to use webpack to move a build.config.xml to config.xml with string replacment: – but this doesn’t seem to work with Ionic’s webpack configuration.

Is there a suggested way to keep hard coded variables out of config.xml?

1 Like

Side note: ionic state was removed with Ionic CLI 3.x - you probably shouldn’t build a big system that is based on it.

Yes I understand that, but this project is built on ionic 2 / cordova 6.5

Ionic 2 doesn’t care which Ionic CLI version or Cordova CLI version you use - you should be able to upgrade with no problems.

Okay; but how do I address my original problem of keeping hard coded stuff out of config.xml? Is this really something no one has ever run into before?