Skip to content

Not Work Correctly With Vite@7 in Dev Mode #288

@JiaxinnSu

Description

@JiaxinnSu

Enviroment: vite@7.3.7 vite-plugin-electron@0.29.0
Start project using npx vite
Main process code to reappear the fault:

import { app, BrowserWindow } from 'electron'

export const VITE_DEV_SERVER_URL = process.env.VITE_DEV_SERVER_URL
let win: BrowserWindow | null = null
async function createWindow() {
  win = new BrowserWindow({
  })
  if (VITE_DEV_SERVER_URL) {
    await win.loadURL(VITE_DEV_SERVER_URL)
    win.webContents.openDevTools()
  }
}
app.whenReady().then(createWindow)

Fault Phenomenon:
The app will crash when save the main process file to restart.
The app will work correctly when save the file twice.
Removing win.webContents.openDevTools(), the app will work correctly .
Using the vite@5.4.11, the app will work correctly .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions