I need to run an electron application in developer mode when I'm running locally and in production mode when the application is built, and I need to read this environment variable during the application.
I am using electron-builder in version 22.8.0 to build the application, and electron is in version 10.0.0.
Thanks :)
If I understand your question, here is what I use to run electron-reload when in development. I think there are other, maybe better ways to do this now, but it has worked really well for me for a few years.
Define a var in the start script:
"scripts": {
"start": "APP_DEV=true electron .",
},
Then read it in main.js:
var isDev = process.env.APP_DEV ? (process.env.APP_DEV.trim() == 'true') : false;
if (isDev) {
require('electron-reload')(__dirname);
}
From the Electron documentation:
app.isPackaged
A
booleanproperty that returnstrueif the app is packaged,falseotherwise. For many apps, this property can be used to distinguish development and production environments.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With