File tree Expand file tree Collapse file tree
display-performance-test-app Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -109,7 +109,18 @@ export default defineConfig(() => {
109109 } ,
110110 } ,
111111 plugins : [
112- ignore ( [ "electron" ] ) , // equivalent to webpack externals
112+ // Externalize electron in both dev and build — resolves to window['electron']
113+ {
114+ name : "vite-plugin-electron-external" ,
115+ resolveId ( id ) {
116+ if ( id === "electron" ) return "\0electron-external" ;
117+ } ,
118+ load ( id ) {
119+ if ( id === "\0electron-external" )
120+ return "export default window['electron'];" ;
121+ } ,
122+ } ,
123+ ignore ( [ "electron" ] ) , // equivalent to webpack externals (build only fallback)
113124 // copy static assets to .static-assets folder
114125 copy ( {
115126 targets : [
@@ -149,9 +160,23 @@ export default defineConfig(() => {
149160 "@itwin/core-mobile/lib/cjs/MobileFrontend" , // import from module error
150161 ] ,
151162 exclude : [
163+ "electron" ,
152164 "@itwin/core-frontend" , //prevents import not resolved errors
153165 "@itwin/core-common" , //prevents rpc errors
154166 ] ,
167+ esbuildOptions : {
168+ plugins : [
169+ {
170+ name : "externalize-electron" ,
171+ setup ( build ) {
172+ build . onResolve ( { filter : / ^ e l e c t r o n $ / } , ( ) => ( {
173+ path : "electron" ,
174+ external : true ,
175+ } ) ) ;
176+ } ,
177+ } ,
178+ ] ,
179+ } ,
155180 } ,
156181 } ;
157182} ) ;
Original file line number Diff line number Diff line change @@ -114,7 +114,18 @@ export default defineConfig(() => {
114114 } ,
115115 } ,
116116 plugins : [
117- ignore ( [ "electron" ] ) , // equivalent to webpack externals
117+ // Externalize electron in both dev and build — resolves to window['electron']
118+ {
119+ name : "vite-plugin-electron-external" ,
120+ resolveId ( id ) {
121+ if ( id === "electron" ) return "\0electron-external" ;
122+ } ,
123+ load ( id ) {
124+ if ( id === "\0electron-external" )
125+ return "export default window['electron'];" ;
126+ } ,
127+ } ,
128+ ignore ( [ "electron" ] ) , // equivalent to webpack externals (build only fallback)
118129 // copy static assets to .static-assets folder
119130 copy ( {
120131 targets : [
@@ -163,9 +174,23 @@ export default defineConfig(() => {
163174 "@itwin/core-mobile/lib/cjs/MobileFrontend" , // import from module error
164175 ] ,
165176 exclude : [
177+ "electron" ,
166178 "@itwin/core-frontend" , //prevents import not resolved errors
167179 "@itwin/core-common" , //prevents rpc errors
168180 ] ,
181+ esbuildOptions : {
182+ plugins : [
183+ {
184+ name : "externalize-electron" ,
185+ setup ( build ) {
186+ build . onResolve ( { filter : / ^ e l e c t r o n $ / } , ( ) => ( {
187+ path : "electron" ,
188+ external : true ,
189+ } ) ) ;
190+ } ,
191+ } ,
192+ ] ,
193+ } ,
169194 } ,
170195 } ;
171196} ) ;
You can’t perform that action at this time.
0 commit comments