1
- import type {
2
- ResolveOptions ,
3
- WebpackPluginInstance ,
4
- Configuration ,
1
+ import {
2
+ type ResolveOptions ,
3
+ type WebpackPluginInstance ,
4
+ type Configuration ,
5
+ ProvidePlugin ,
5
6
} from 'webpack' ;
6
7
import { merge } from 'webpack-merge' ;
7
8
import ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin' ;
@@ -110,6 +111,11 @@ const sharedResolveOptions = (
110
111
} ;
111
112
} ;
112
113
114
+ const providePlugin = new ProvidePlugin ( {
115
+ URL : [ 'whatwg-url' , 'URL' ] ,
116
+ URLSearchParams : [ 'whatwg-url' , 'URLSearchParams' ] ,
117
+ } ) ;
118
+
113
119
export function createElectronMainConfig (
114
120
args : Partial < ConfigArgs >
115
121
) : WebpackConfig {
@@ -212,6 +218,7 @@ export function createElectronRendererConfig(
212
218
plugins : [
213
219
...entriesToHtml ( entries ) ,
214
220
new WebpackPluginMulticompilerProgress ( ) ,
221
+ providePlugin ,
215
222
] ,
216
223
node : false as const ,
217
224
externals : toCommonJsExternal ( sharedExternals ) ,
@@ -339,8 +346,9 @@ export function createWebConfig(args: Partial<ConfigArgs>): WebpackConfig {
339
346
...sharedResolveOptions ( opts . target ) ,
340
347
} ,
341
348
ignoreWarnings : sharedIgnoreWarnings ,
342
- plugins :
343
- isServe ( opts ) && opts . hot
349
+ plugins : [
350
+ providePlugin ,
351
+ ...( isServe ( opts ) && opts . hot
344
352
? [
345
353
// Plugin types are not matching Webpack 5, but they work
346
354
new ReactRefreshWebpackPlugin ( ) as unknown as WebpackPluginInstance ,
@@ -355,7 +363,8 @@ export function createWebConfig(args: Partial<ConfigArgs>): WebpackConfig {
355
363
356
364
new DuplicatePackageCheckerPlugin ( ) ,
357
365
]
358
- : [ ] ,
366
+ : [ ] ) ,
367
+ ] ,
359
368
} ;
360
369
}
361
370
0 commit comments