You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to make an Electron app with Sveltekit. I am currently using electron-forge and adapter-static.
I basically want to create an SPA with Sveltekit and then let Electron serve the files. The problem right now is that when I use the built code and point Electron to serve index.html, there are files that Electron can't find because the paths are absolute and not relative. Even when using router.type="hash", it seems like Electron is trying to access files that are supposed to be modulepreloaded.
Since router.type="hash" is mainly used for client exclusive apps, I'd assume that it should be able to be loaded by being served the file through file:// instead of needing a web server because isn't that the whole point of making it client rendered?
if you run pnpm run package or pnpm run make, the resulting build will vite build the sveltekit app into .vite/renderer/main_window and then runs electron-forge package/make. these files work fine when you run vite preview however when Electron serves the files with mainWindow.loadFile, it seems to not be able to find the files due to the absolute pathing.
you can see the error if you go to the out directory after you've run pnpm run package or pnpm run make and go to out/electron-svelte-<your architecture here> and open the electron app. once the electron window opens, you can open dev tools with the shortcut cmd + alt + i. you can also see the files that electron uses if you go to out/electron-svelte-<your achitecture here>/electron-svelte.app/Contents/Resources and run npx @electron/asar extract app.asar asar and it will dump all the bundled files into the asar directory.
Hash based routing was advertised to being able useful for Electron apps, but just enabling hash based routing doesn't make it automatically work.
I've heard that using electron-serve can solve the issues as it basically acts as a intermediary web server, but doesn't that ruin the whole point of creating a SPA that's run only on the client. This goes for embedded systems and tv apps too.
Is there a way to serve a Sveltekit app using file://?
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
I am trying to make an Electron app with Sveltekit. I am currently using
electron-forge
andadapter-static
.I basically want to create an SPA with Sveltekit and then let Electron serve the files. The problem right now is that when I use the built code and point Electron to serve
index.html
, there are files that Electron can't find because the paths are absolute and not relative. Even when usingrouter.type="hash"
, it seems like Electron is trying to access files that are supposed to bemodulepreload
ed.Since
router.type="hash"
is mainly used forclient
exclusive apps, I'd assume that it should be able to be loaded by being served the file throughfile://
instead of needing a web server because isn't that the whole point of making itclient
rendered?Reproduction
demo repo
if you run
pnpm run package
orpnpm run make
, the resulting build willvite build
the sveltekit app into.vite/renderer/main_window
and then runselectron-forge package/make
. these files work fine when you runvite preview
however when Electron serves the files withmainWindow.loadFile
, it seems to not be able to find the files due to the absolute pathing.you can see the error if you go to the
out
directory after you've runpnpm run package
orpnpm run make
and go toout/electron-svelte-<your architecture here>
and open the electron app. once the electron window opens, you can open dev tools with the shortcutcmd + alt + i
. you can also see the files that electron uses if you go toout/electron-svelte-<your achitecture here>/electron-svelte.app/Contents/Resources
and runnpx @electron/asar extract app.asar asar
and it will dump all the bundled files into theasar
directory.Logs
System Info
Severity
blocking all usage of SvelteKit
Additional Information
Hash based routing was advertised to being able useful for
Electron
apps, but just enabling hash based routing doesn't make it automatically work.I've heard that using
electron-serve
can solve the issues as it basically acts as a intermediary web server, but doesn't that ruin the whole point of creating a SPA that's run only on the client. This goes for embedded systems and tv apps too.Is there a way to serve a Sveltekit app using
file://
?The text was updated successfully, but these errors were encountered: