caoxiemeihao / nuxt-electron

Integrate Nuxt and Electron
MIT License
184 stars 21 forks source link

[BUG] Path to entry file not good on reload in production mode (built) #33

Closed LouisMazel closed 1 year ago

LouisMazel commented 1 year ago

Bug

In your "quick-start" example, at the first open of the application all is good, the application load the index.html from the .output/public

But when you reload the app with "CMD + R", the index.html is not found.

The url/path provided with win.loadFile(path.join(process.env.VITE_PUBLIC!, 'index.html')) in electron/main.ts doesn’t seem to be good.

main_large

The request URL is:

file:///Users/mazel/Downloads/nuxt-electron-main/examples/quick-start/release/0.0.0/mac-arm64/nuxt-electron-quick-start.app/Contents/Resources/app/.output/public/Users/mazel/Downloads/nuxt-electron-main/examples/quick-start/release/0.0.0/mac-arm64/nuxt-electron-quick-start.app/Contents/Resources/app/.output/public/index.html

but should be

file:///Users/mazel/Downloads/nuxt-electron-main/examples/quick-start/release/0.0.0/mac-arm64/nuxt-electron-quick-start.app/Contents/Resources/app/.output/public/index.html

An unexpected path is added at the beginning after file:// : Users/mazel/Downloads/nuxt-electron-main/examples/quick-start/release/0.0.0/mac-arm64/nuxt-electron-quick-start.app/Contents/Resources/app/.output/public

Solution ?

It's not possible to load a file from the Application Contents directly?

Something like: mainWindow.loadURL('app://./.output/public/index.html')

caoxiemeihao commented 1 year ago

Hey 👋 Thanks feedback, we need to use http://localhost:port based on http ensure the HMR works. So, I'll try resolve it.

LouisMazel commented 1 year ago

Hi,

Sorry I forgot to mention it but my issue concerns the production mode. The bug appears only with the built app.

That why the bug appear with the file ´index.html´

caoxiemeihao commented 1 year ago

You can try tu use v0.5.0 again


Still has the BUG :(

LouisMazel commented 1 year ago

I upgraded:

And I don't have the bug anymore!

Thanks