File tree 2 files changed +6
-3
lines changed
2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change 1
1
import { app , BrowserWindow } from 'electron'
2
+ import { fileURLToPath } from 'node:url'
2
3
import path from 'node:path'
3
4
5
+ globalThis . __filename = fileURLToPath ( import . meta. url )
6
+ globalThis . __dirname = path . dirname ( __filename )
7
+
4
8
// The built directory structure
5
9
//
6
10
// ├─┬─┬ dist
7
11
// │ │ └── index.html
8
12
// │ │
9
13
// │ ├─┬ dist-electron
10
14
// │ │ ├── main.js
11
- // │ │ └── preload.js
15
+ // │ │ └── preload.mjs
12
16
// │
13
17
process . env . APP_ROOT = path . join ( __dirname , '..' )
14
18
@@ -25,7 +29,7 @@ function createWindow() {
25
29
win = new BrowserWindow ( {
26
30
icon : path . join ( process . env . VITE_PUBLIC , 'electron-vite.svg' ) ,
27
31
webPreferences : {
28
- preload : path . join ( __dirname , 'preload.js ' ) ,
32
+ preload : path . join ( __dirname , 'preload.mjs ' ) ,
29
33
} ,
30
34
} )
31
35
Original file line number Diff line number Diff line change @@ -262,7 +262,6 @@ function setupElectron(root: string, framework: Framework) {
262
262
editFile ( path . join ( root , 'package.json' ) , content => {
263
263
const json = JSON . parse ( content )
264
264
json . main = 'dist-electron/main.js'
265
- json . type = undefined // Electron(24-) only support CommonJs now
266
265
json . scripts . build = `${ json . scripts . build } && electron-builder`
267
266
json . devDependencies . electron = pkg . devDependencies . electron
268
267
json . devDependencies [ 'electron-builder' ] = pkg . devDependencies [ 'electron-builder' ]
You can’t perform that action at this time.
0 commit comments