Open thombruce opened 1 year ago
Deleting a bunch of Vite config does result in the app launching in a browser, but the page is blank and there's this error...
caught ReferenceError: __dirname is not defined
at node_modules/electron/index.js (index.js:4:28)
at __require2 (chunk-7FP5O474.js?v=f21ed066:10:50)
at index.js:21:34
Can't yet see where, if anywhere, I'm still trying to import Electron...
We're coming at the problem backwards. Typically, one would have browser support and look to add Electron after that. Worth creating a simple Vite+Vue project that runs in the browser and examining the steps to add Electron; work the problem backwards from there.
Not all the way there yet. There's a big change to the Vite config that needs making, but these are the non-disruptive changes I've had to make to prepare this to work: https://github.com/thombruce/marmalade/pull/39/commits/fc254c370e52514a6926378a3c4d663c1fac6949
The Vite config changes are sort of an either Electron or browser thing, and we want to do both. So yet to figure that out.
But the changes do enable me to use the app in browser exactly as intended.
The issue is actually this line: https://github.com/thombruce/marmalade/blob/6fd1a51f8d6ce2f1ae31cb8775f450ead4edb972/vite.config.ts#L61
Electron doesn't work without this renderer, browser doesn't work with it. We're going to need to figure out how to handle conditionals in Vite config, it seems.
The current Vite Electron plugin can probably be replaced with another that works better with the dual-build we're going for.
Yeah, replacing https://github.com/electron-vite/vite-plugin-electron with https://evite.netlify.app/ which has a separate build process and seemingly better documentation.
As of https://github.com/thombruce/marmalade/pull/39/commits/c431d96efd5039ffd835214f090fe6e53f720fdb, the Electron build still isn't working but the browser build is... and I'm pretty sure the Electron plugin just has issues with the default Electron scripts provided by the other template, so I really just need to amend those to a solution that works with the new plugin.
This is approaching levels of... not worth it right now.
Swapping out one Electron plugin for another does work, I can get it building, but the app is still failing. There are just too many code changes that need to be done at this stage - it's a pretty major refactor to swap plugins.
Closing the PR and... we'll revisit this again in the future.
Self-explanatory: Marmalade should work in a web browser. Bonus points for PWA offline support, but we might kick that to a future issue to keep PRs nice and lean.