Access process.env.NODE_ENV at runtime

Hi all!
Would anyone know how to access compile target environment at runtime within the app.
Use case: I use cordova-plugin-admob-free plugin to show add. At runtime it takes a configuration flag isTesting which needs to be true at dev time but on production needs to be set to false. Based on webpack.config.js this would accurately map to env variable set to production vs development.

Ideally I would love to just test for: const isTesting = process.env.NODE_ENV !== 'production' but of course node env is not available at runtime on Cordova.

Perhaps there is a way to do something at webpack level and set some global variables there based on node env?

Any pointers how you guys solve such needs?

Just to answer my own question.
process.env.NODE_ENV and process.env.TARGET are indeed available at runtime to the app because of the webpack “DefinePlugin” plugin. So to differentiate between production and development builds one could easily do process.env.NODE_ENV === 'production'.

Additional note is that when paused with debugger within chrome dev tools this variable was not defined when checking on the console so that was what threw me off the course.

1 Like