Skip to content

Commit 1723b11

Browse files
authored
Merge pull request #763 from Adamant-im/fix/electron-build-esm
fix: electron build esm
2 parents 141160e + e6db298 commit 1723b11

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/electron/main.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { app, BrowserWindow, Menu, nativeTheme, protocol } from 'electron'
2+
import { fileURLToPath, URL } from 'node:url'
23
import installExtension, { REDUX_DEVTOOLS } from 'electron-devtools-installer'
3-
import path from 'path'
4-
import { readFile } from 'fs'
5-
import { URL } from 'url'
4+
import path from 'node:path'
5+
import { readFile } from 'node:fs'
66

77
const SCHEME = 'app'
8+
const __filename = fileURLToPath(import.meta.url)
9+
const __dirname = path.dirname(__filename)
810

911
// Keep a global reference of the window object, if you don't, the window will
1012
// be closed automatically when the JavaScript object is garbage collected

vite-base.config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import vue from '@vitejs/plugin-vue'
33
import vueJsx from '@vitejs/plugin-vue-jsx'
44
import wasm from 'vite-plugin-wasm'
55
import topLevelAwait from 'vite-plugin-top-level-await'
6-
import path from 'path'
6+
import path from 'node:path'
77
import autoprefixer from 'autoprefixer'
88
import inject from '@rollup/plugin-inject'
99
import commonjs from '@rollup/plugin-commonjs'
10+
import { fileURLToPath } from 'node:url'
1011

1112
import { deferScripsPlugin } from './vite-config/plugins/deferScriptsPlugin'
1213
import { preloadCSSPlugin } from './vite-config/plugins/preloadCSSPlugin'
@@ -15,6 +16,9 @@ import { excludeBip39Wordlists } from './vite-config/rollup/excludeBip39Wordlist
1516
const env = loadEnv('production', process.cwd())
1617
const basePublicPath = env.VITE_PUBLIC_PATH || '/'
1718

19+
const __filename = fileURLToPath(import.meta.url)
20+
const __dirname = path.dirname(__filename)
21+
1822
export default defineConfig({
1923
base: basePublicPath,
2024
plugins: [

0 commit comments

Comments
 (0)