
Set NODE_ENV at run time or build time to switch the app between dev and production modes. At build time, the current NODE_ENV will be included in the packaged app's package.json file. At runtime we read NODE_ENV from package.json, but also allow the local environment variable to override. A query string parsed by a preload script exposes the value to the renderer, which then determines whether we use the staging or production server. Additionally, different environments have different user data directories. // FREEBIE
11 lines
296 B
JavaScript
11 lines
296 B
JavaScript
/*
|
|
* Pending electron 1.6.x
|
|
* const env = require('url').parse(window.location, true).query;
|
|
*/
|
|
|
|
window.env = {};
|
|
window.location.search.substring(1).split('&').forEach(function(variable) {
|
|
var pair = variable.split('=');
|
|
env[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
|
|
});
|