From 93a4cd74f1d4aba4ed0b84055b312b0257a1c679 Mon Sep 17 00:00:00 2001 From: xhayper Date: Tue, 27 Dec 2022 08:30:49 +0700 Subject: [PATCH 1/2] chore: update dependencies --- electron/main/index.ts | 11 +++++------ package.json | 6 +++--- vite.config.ts | 3 +-- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/electron/main/index.ts b/electron/main/index.ts index 5daee09..d99e0cf 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -12,7 +12,7 @@ import { join } from 'node:path' // ├─┬ dist // │ └── index.html > Electron-Renderer // -process.env.DIST_ELECTRON = join(__dirname, '..') +process.env.DIST_ELECTRON = join(__dirname, '../') process.env.DIST = join(process.env.DIST_ELECTRON, '../dist') process.env.PUBLIC = process.env.VITE_DEV_SERVER_URL ? join(process.env.DIST_ELECTRON, '../public') @@ -38,7 +38,7 @@ let win: BrowserWindow | null = null // Here, you can also use other preload const preload = join(__dirname, '../preload/index.js') const url = process.env.VITE_DEV_SERVER_URL -const indexHtml = join('dist/', 'index.html') +const indexHtml = join(process.env.DIST, 'index.html') async function createWindow() { win = new BrowserWindow({ @@ -54,11 +54,10 @@ async function createWindow() { }, }) - // Open devTool if the app is not packaged - win.webContents.openDevTools() - if (process.env.VITE_DEV_SERVER_URL) { // electron-vite-vue#298 win.loadURL(url) + // Open devTool if the app is not packaged + win.webContents.openDevTools() } else { win.loadFile(indexHtml) } @@ -114,4 +113,4 @@ ipcMain.handle('open-win', (_, arg) => { } else { childWindow.loadFile(indexHtml, { hash: arg }) } -}) +}) \ No newline at end of file diff --git a/package.json b/package.json index 2ebfdea..a82e875 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "electron-vite-react", "version": "2.1.0", - "main": "dist-electron/electron/main/index.js", + "main": "dist-electron/main/index.js", "description": "Electron Vite React boilerplate.", "author": "草鞋没号 <308487730@qq.com>", "license": "MIT", @@ -18,7 +18,7 @@ }, "devDependencies": { "@types/react": "^18.0.26", - "@types/react-dom": "^18.0.9", + "@types/react-dom": "^18.0.10", "@vitejs/plugin-react": "^3.0.0", "electron": "^22.0.0", "electron-builder": "^23.6.0", @@ -27,7 +27,7 @@ "sass": "^1.57.1", "typescript": "^4.9.4", "vite": "^4.0.3", - "vite-electron-plugin": "^0.6.0", + "vite-electron-plugin": "^0.6.3", "vite-plugin-electron-renderer": "^0.11.3" }, "engines": { diff --git a/vite.config.ts b/vite.config.ts index 77f564a..2bd3f42 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -23,8 +23,7 @@ export default defineConfig({ react(), electron({ include: [ - 'electron', - 'preload', + 'electron' ], transformOptions: { sourcemap: isDevelopment From 0b463ba8c34badc052feeedf0f030d9fea250c9c Mon Sep 17 00:00:00 2001 From: xhayper Date: Tue, 27 Dec 2022 09:26:46 +0700 Subject: [PATCH 2/2] feat: shamefully hoist --- .npmrc | 1 + 1 file changed, 1 insertion(+) create mode 100644 .npmrc diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..c483022 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +shamefully-hoist=true \ No newline at end of file