Search code examples
cordovaenvironment-variablesapache-cordova

Getting environment variables from Apache Cordova


i have some questions about using Apache Cordova. As you see the title, is it possible to get environment variables from Cordova? I searched on google almost half-a-day, but still i cannot found. Also i looked up for Cordova Plugin Registry, but either not found.

What i want to do is setting some kind of environment variable to "production" or "development" like NODE_ENV in Node.js. It will be very appreciated that anyone give me a hand ;)


Solution

  • You can use Cordova hooks to check an environment variable (i.e. NODE_ENV) and then configure your app appropriately. Example here: http://www.kdmooreconsulting.com/blogs/build-a-cordova-hook-to-setup-environment-specific-constants/