Skip to content

Commit 2512ad1

Browse files
committed
feat: Allow use import.meta.env.VITE_SOME_KEY in Electron-Main
1 parent b2ef751 commit 2512ad1

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

vite.config.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { rmSync } from 'fs'
22
import { defineConfig } from 'vite'
33
import vue from '@vitejs/plugin-vue'
44
import electron from 'vite-electron-plugin'
5-
import { customStart } from 'vite-electron-plugin/plugin'
5+
import { customStart, loadViteEnv } from 'vite-electron-plugin/plugin'
66
import renderer from 'vite-plugin-electron-renderer'
77
import pkg from './package.json'
88

@@ -17,10 +17,16 @@ export default defineConfig({
1717
transformOptions: {
1818
sourcemap: !!process.env.VSCODE_DEBUG,
1919
},
20-
// Will start Electron via VSCode Debug
21-
plugins: process.env.VSCODE_DEBUG
22-
? [customStart(debounce(() => console.log(/* For `.vscode/.debug.script.mjs` */'[startup] Electron App')))]
23-
: undefined,
20+
plugins: [
21+
...(process.env.VSCODE_DEBUG
22+
? [
23+
// Will start Electron via VSCode Debug
24+
customStart(debounce(() => console.log(/* For `.vscode/.debug.script.mjs` */'[startup] Electron App'))),
25+
]
26+
: []),
27+
// Allow use `import.meta.env.VITE_SOME_KEY` in Electron-Main
28+
loadViteEnv(),
29+
],
2430
}),
2531
// Use Node.js API in the Renderer-process
2632
renderer({

0 commit comments

Comments
 (0)