electron-vite-react
electron-vite-react copied to clipboard
How to setup auto reload the app when the files of main process are updated?
For example I'm using IPC, but when change an implementation of a method of the IPC, this change is not showed in real time like when do a change in the renderer, currently I do manually restart to see the changes in the app.
Example: https://github.com/MiniSuperDev/electron-vite-react-main-reload/tree/main
- Click this button
- Check the message
- Change the implementation in the main process
Change this:
https://github.com/MiniSuperDev/electron-vite-react-main-reload/blob/main/electron/main/index.ts#L123-L128
For this:
ipcMain.handle("getDate", () => {
return `Other String:` + `${Date.now()}`;
});
- Save and click the button again
You notice that the message is the previous.
- Restart the app to see the new implementation
I think it should restart the app, or do a hot reload if possible. Thanks
Please provide a minimum demo. thanks
@RSS1102 Hi, I update the issue with an example
ipcMain.handle("getDate", () => {
return `Other String:` + `${Date.now()}`;
})
This is the code for the Electron process. When you try to change the code here and save it, the program will reload.. This is inevitable
https://github.com/electron-vite/electron-vite-react/assets/81673017/a324c528-f7f7-470e-92f7-2a150eb95c4c
@RSS1102 I see, in my VS Code, when save it, it not reload the app, so I need to restart manually
@RSS1102 I see, in my VS Code, when save it, it not reload the app, so I need to restart manually
I'm not quite sure about this, maybe it's because of your vscode? If possible, you can try changing to a different computer.
@RSS1102 I checked, it works when you run from npm run dev
But the error happens (not reload) when launch using the vs code launch Debug App (F5)
https://github.com/MiniSuperDev/electron-vite-react-main-reload/blob/2793a6831a87a5da20a279a0b549aa3c53858249/.vscode/launch.json#L8
I have the same problem (I think, it's a bit hard to understand). When I change something in src\main\index.ts for example ipcMain.on('ping', () => console.log('ponggggg')) I need to stop and start the application again. there is no hot reload or anything for the main process. I'm just using npm run dev nothing else.