Skip to content

Commit

Permalink
electron: Fix build code for vite-plugin-electron to activate HMR
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaellehmkuhl committed Oct 9, 2024
1 parent b3ec6b1 commit e8dea79
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 5 additions & 1 deletion electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ function createWindow(): void {
mainWindow?.webContents.send('main-process-message', new Date().toLocaleString())
})

mainWindow.loadFile(join(ROOT_PATH.dist, 'index.html'))
if (process.env.VITE_DEV_SERVER_URL) {
mainWindow.loadURL(process.env.VITE_DEV_SERVER_URL)
} else {
mainWindow.loadFile(join(ROOT_PATH.dist, 'index.html'))
}
}

app.on('window-all-closed', () => {
Expand Down
9 changes: 6 additions & 3 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ const path = require('path') // eslint-disable-line @typescript-eslint/no-var-re
export default defineConfig({
plugins: [
electron({
main: {
entry: 'electron/main.ts',
entry: 'electron/main.ts',
vite: {
build: {
outDir: 'dist/electron',
},
},
}).filter((configuration) => configuration.apply === 'build'),
}),
vue(),
vuetify({
autoImport: true,
Expand Down

0 comments on commit e8dea79

Please sign in to comment.