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 b1dc119
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ coverage/
dist/
node_modules/
dev-dist/
dist-electron/

cypress/fixtures/
cypress/videos/
Expand Down
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "cockpit",
"version": "0.0.0",
"private": true,
"main": "dist/electron/main.js",
"main": "dist-electron/main.js",
"description": "An intuitive and customizable cross-platform ground control station for remote vehicles of all types.",
"scripts": {
"build": "vite build",
Expand Down
6 changes: 2 additions & 4 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ const path = require('path') // eslint-disable-line @typescript-eslint/no-var-re
export default defineConfig({
plugins: [
electron({
main: {
entry: 'electron/main.ts',
},
}).filter((configuration) => configuration.apply === 'build'),
entry: 'electron/main.ts',
}),
vue(),
vuetify({
autoImport: true,
Expand Down

0 comments on commit b1dc119

Please sign in to comment.