Correct loadURL for building in electron app with react?

687 Views Asked by At

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

There are 1 best solutions below

0
On

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`);