Skip to content

Commit

Permalink
electron: Add dedicated dev:electron command that spawns the electr…
Browse files Browse the repository at this point in the history
…on window

The default `dev` command will only serve the web-page, as usual.
  • Loading branch information
rafaellehmkuhl authored and ArturoManzoli committed Oct 15, 2024
1 parent 9c537c8 commit 2f5b723
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"deploy:electron": "electron-builder --publish=never -c.extraMetadata.version=$(git describe --tags --abbrev=0 | sed 's/^v//')",
"deploy:flatpak": "electron-builder --x64 --linux flatpak",
"dev": "vite --host",
"dev:electron": "ELECTRON=true vite --host",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --ignore-path .gitignore --max-warnings=0",
"lint:fix": "eslint --fix . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --ignore-path .gitignore --max-warnings=0",
"preview": "vite preview --port 5050",
Expand Down
36 changes: 20 additions & 16 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,28 @@ import vuetify from 'vite-plugin-vuetify'

const path = require('path') // eslint-disable-line @typescript-eslint/no-var-requires

// Check if we're running in Electron mode
const isElectron = process.env.ELECTRON === 'true'

export default defineConfig({
plugins: [
electron({
entry: 'electron/main.ts',
vite: {
build: {
outDir: 'dist/electron',
isElectron &&
electron({
entry: 'electron/main.ts',
vite: {
build: {
outDir: 'dist/electron',
},
},
},
onstart: () => {
// @ts-ignore: process.electronApp exists in vite-plugin-electron but not in the types
if (process.electronApp) {
// @ts-ignore: process.electronApp.pid exists in vite-plugin-electron but not in the types
treeKillSync(process.electronApp.pid)
}
startup()
},
}),
onstart: () => {
// @ts-ignore: process.electronApp exists in vite-plugin-electron but not in the types
if (process.electronApp) {
// @ts-ignore: process.electronApp.pid exists in vite-plugin-electron but not in the types
treeKillSync(process.electronApp.pid)
}
startup()
},
}),
vue(),
vuetify({
autoImport: true,
Expand All @@ -35,7 +39,7 @@ export default defineConfig({
},
includeAssets: ['favicon.ico', 'apple-touch-icon.png', 'masked-icon.svg'],
}),
],
].filter(Boolean),
define: { 'process.env': {} },
resolve: {
alias: {
Expand Down

0 comments on commit 2f5b723

Please sign in to comment.