0
votes

What should i put for mainWindow.loadURL in my electron app build with react? Currently i have

  mainWindow.loadURL('file://' + path.join(__dirname, '../build/index.html'));

And it works fine in development while running 'npm run electron' but when i try to build my application and start the app by clicking the application icon, I only see blanc white window.

I think this has to do with the path, but if you guys have any other ideas that might cause this feel free to tell..

I am running MacOS 10.14

1
The path to your index.html may be different after building the app. If you find yourself with 2 different paths for dev and packaged - app.isPackaged may be helpful here.Rhayene

1 Answers

0
votes

This occurs because of the incorrect link between the build folder and the entry point of your application.

You can try it with a template literal like this:

mainWindow.loadURL(`file://${__dirname}/../build/index.html`);