If your are making use of electron to build a web application and you are trying to implement worker. There 3 ways I currently know
- Just use plain javascript
- Make use of esbuild to bundle your typescript
- Make use of electron vite esbuild config.
We would be looking at electron vite with es build.
The image above is all you really need.
Once you have create your workers(in .ts) in you main folder, Initialized them inside your index.ts for main folder where mainWindow is initialzed. Once worker created and initialized then go to add it to the electron vite config.js/ts file under you main object (just like in the image above). After this just run your code again all should work well.
This write up is rushed(was very busy just decided to quickly journal this so another person does not go through hell like i went through trying setup workers in electron vite )
To understand this more read the electron vite docs,electron js docs and nodejs workers docs.
Top comments (0)