Skip to content

Commit 4f796e4

Browse files
committed
perf: ignore browser field and additional node condition for main config
1 parent 3def0ed commit 4f796e4

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/plugins/electron.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ export function electronMainVitePlugin(options?: ElectronPluginOptions): Plugin[
4949
const nodeTarget = getElectronNodeTarget()
5050

5151
const defaultConfig = {
52+
resolve: {
53+
browserField: false,
54+
mainFields: ['module', 'jsnext:main', 'jsnext'],
55+
conditions: ['node']
56+
},
5257
build: {
5358
outDir: path.resolve(root, 'out', 'main'),
5459
target: nodeTarget,
@@ -83,6 +88,8 @@ export function electronMainVitePlugin(options?: ElectronPluginOptions): Plugin[
8388
const buildConfig = mergeConfig(defaultConfig.build, build)
8489
config.build = buildConfig
8590

91+
config.resolve = mergeConfig(defaultConfig.resolve, config.resolve || {})
92+
8693
config.define = config.define || {}
8794
config.define = { ...processEnvDefine(), ...config.define }
8895

@@ -151,6 +158,11 @@ export function electronPreloadVitePlugin(options?: ElectronPluginOptions): Plug
151158
const nodeTarget = getElectronNodeTarget()
152159

153160
const defaultConfig = {
161+
resolve: {
162+
browserField: false,
163+
mainFields: ['module', 'jsnext:main', 'jsnext'],
164+
conditions: ['node']
165+
},
154166
build: {
155167
outDir: path.resolve(root, 'out', 'preload'),
156168
target: nodeTarget,
@@ -185,6 +197,8 @@ export function electronPreloadVitePlugin(options?: ElectronPluginOptions): Plug
185197
const buildConfig = mergeConfig(defaultConfig.build, build)
186198
config.build = buildConfig
187199

200+
config.resolve = mergeConfig(defaultConfig.resolve, config.resolve || {})
201+
188202
config.define = config.define || {}
189203
config.define = { ...processEnvDefine(), ...config.define }
190204

0 commit comments

Comments
 (0)