Closed BastienCivel closed 3 years ago
The production app has no access to the environment variable you set in your npm run script. You need to set the environment variable inside your app. However, your question has nothing specifically to do with this package, so ask on Stack Overflow for any follow-up questions.
Hello ! I'm kinda new to electron, but so far, everything is work like I want to. I'm buildin a react electron app, and i'm at the process of building it. I'm using electron_builder to do so. I'm also using this electron-is-dev to simply check if I should set the window frameless or not and open devtools or not. So far, it is working correctly in development and in production. Now, I'm asked to be able to build a production version where I can debug it, meaning having a frame window and devtools open. In the documentation, I saw that we can set the environment variable ELECTRON_IS_DEV to 1 to force the dev mode. But it is not working for me. I'm calling this script to build with debug:
"electron-build-local-win": "cross-env ELECTRON_IS_DEV=1 electron-builder build --win --publish never --ia32"
And my electron.js(entry point) looks like this (for the interesting part): `const { app, BrowserWindow, ipcMain } = require('electron'); const { autoUpdater } = require('electron-updater'); const path = require('path'); const isDev = require('electron-is-dev');
let mainWindow;
function createWindow() { mainWindow = new BrowserWindow({ width: 600, height: 800, frame: isDev, webPreferences: { nodeIntegration: true, contextIsolation: false, enableRemoteModule: true, preload: 'src/Electron/AutoUpdater.ts', }, }); mainWindow.loadURL(isDev ? 'http://localhost:3000' :
file://${__dirname}/index.html
); mainWindow.maximize(); if(isDev) { mainWindow.webContents.openDevTools(); }`So I was thinking I could just change the environment variable while calling the script, but it is not working so far. What did I miss ?
Thanks in advance !