mirror of
https://github.com/alex8088/electron-vite.git
synced 2025-04-06 04:05:44 +08:00
Merge pull request #39 from ianstormtaylor/patch-1
perf: use `require.resolve` to find electron package
This commit is contained in:
commit
a62b20359b
@ -511,8 +511,8 @@ export function externalizeDepsPlugin(options: ExternalOptions = {}): Plugin | n
|
||||
function getElectronMainVer(root: string): string {
|
||||
let mainVer = process.env.ELECTRON_MAIN_VER || ''
|
||||
if (!mainVer) {
|
||||
const electronModulePath = path.resolve(root, 'node_modules', 'electron')
|
||||
const pkg = path.join(electronModulePath, 'package.json')
|
||||
const electronModulePath = require.resolve('electron')
|
||||
const pkg = path.join(electronModulePath, '../package.json')
|
||||
if (fs.existsSync(pkg)) {
|
||||
const require = createRequire(import.meta.url)
|
||||
const version = require(pkg).version
|
||||
|
Loading…
x
Reference in New Issue
Block a user