feat: Allow use `import.meta.env.VITE_SOME_KEY` in Electron-Main
This commit is contained in:
parent
a8d24cb084
commit
c711938f70
|
@ -3,7 +3,7 @@ import path from 'path'
|
||||||
import { defineConfig } from 'vite'
|
import { defineConfig } from 'vite'
|
||||||
import react from '@vitejs/plugin-react'
|
import react from '@vitejs/plugin-react'
|
||||||
import electron from 'vite-electron-plugin'
|
import electron from 'vite-electron-plugin'
|
||||||
import { customStart } from 'vite-electron-plugin/plugin'
|
import { customStart, loadViteEnv } from 'vite-electron-plugin/plugin'
|
||||||
import renderer from 'vite-plugin-electron-renderer'
|
import renderer from 'vite-plugin-electron-renderer'
|
||||||
import pkg from './package.json'
|
import pkg from './package.json'
|
||||||
|
|
||||||
|
@ -27,10 +27,16 @@ export default defineConfig({
|
||||||
transformOptions: {
|
transformOptions: {
|
||||||
sourcemap: !!process.env.VSCODE_DEBUG,
|
sourcemap: !!process.env.VSCODE_DEBUG,
|
||||||
},
|
},
|
||||||
|
plugins: [
|
||||||
|
...(process.env.VSCODE_DEBUG
|
||||||
|
? [
|
||||||
// Will start Electron via VSCode Debug
|
// Will start Electron via VSCode Debug
|
||||||
plugins: process.env.VSCODE_DEBUG
|
customStart(debounce(() => console.log(/* For `.vscode/.debug.script.mjs` */'[startup] Electron App'))),
|
||||||
? [customStart(debounce(() => console.log(/* For `.vscode/.debug.script.mjs` */'[startup] Electron App')))]
|
]
|
||||||
: undefined,
|
: []),
|
||||||
|
// Allow use `import.meta.env.VITE_SOME_KEY` in Electron-Main
|
||||||
|
loadViteEnv(),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
renderer({
|
renderer({
|
||||||
nodeIntegration: true,
|
nodeIntegration: true,
|
||||||
|
|
Loading…
Reference in New Issue