-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot use createElectronRouter with electron-vite #28
Comments
i've been battling this all dayyyy |
i guess you dont need to |
@dantman @sebbean Could you please try this preview and see if the issue is resolved?
This preview adds the it must work by providing it in the export const { Router, registerRoute, settings } = createElectronRouter({
// port: 4927,
devServerUrl: 'http://localhost:4927',
types: {
ids: ['main'],
},
}) or in the registerRoute({
id: 'main',
browserWindow: mainWindow,
devServerUrl: 'http://localhost:4927',
htmlFile: path.join(__dirname, '../renderer/index.html'),
}) if it is necessary to pass an env var, this must be done in the registerRoute method (main process) |
I just tried adding electron-router-dom to a project using electron-vite but ran into a roadblock when trying to refactor the code that calls loadURL/loadFile to use createElectronRouter.
The code in question is written like so, which seems to be effectively what electron-vite's HMR guide suggests.
I examined createElectronRouter to see if there's some way I could make it happy, but it appears this cannot be refactored to ELECTRON_RENDERER_URL without some something extra.
const devServerUrl = `http://localhost:${props.port ?? port}`;
is hardcoded, so there's no easy way to pass in ELECTRON_RENDERER_URL. This would be simple if devServerUrl were an option.const URLRoute = createURLRoute(devServerUrl, windowId, {
also hardcodes the assumption that loadURL points to the root path. Which won't work if that is not the case. I know electron-router-dom is supposed to be taking care of routing but in this case the multi-page pattern is used because the other html document is a special case like a status window that doesn't fit into being part of the router.The text was updated successfully, but these errors were encountered: