mirror of
https://github.com/electron-vite/electron-vite-vue
synced 2025-07-01 21:13:57 +08:00
faet: support use Node.js package
This commit is contained in:
parent
b6ffbf7fce
commit
7ba9a5a368
@ -1,5 +1,15 @@
|
|||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
|
import { builtinModules } from 'module'
|
||||||
import { defineConfig } from 'vite-plugin-electron'
|
import { defineConfig } from 'vite-plugin-electron'
|
||||||
|
import pkg from './package.json'
|
||||||
|
|
||||||
|
const external = [
|
||||||
|
'electron',
|
||||||
|
...builtinModules,
|
||||||
|
// @ts-ignore
|
||||||
|
// For use Node.js package in Electron-main, Preload-script
|
||||||
|
...Object.keys(pkg.dependencies || {}),
|
||||||
|
]
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
main: {
|
main: {
|
||||||
@ -8,6 +18,9 @@ export default defineConfig({
|
|||||||
build: {
|
build: {
|
||||||
sourcemap: false,
|
sourcemap: false,
|
||||||
outDir: 'dist/electron/main',
|
outDir: 'dist/electron/main',
|
||||||
|
rollupOptions: {
|
||||||
|
external,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -21,6 +34,9 @@ export default defineConfig({
|
|||||||
// For debug
|
// For debug
|
||||||
sourcemap: 'inline',
|
sourcemap: 'inline',
|
||||||
outDir: 'dist/electron/preload',
|
outDir: 'dist/electron/preload',
|
||||||
|
rollupOptions: {
|
||||||
|
external,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user