This process is done via v8 bytecode compilation, to get more knowledge about it, please, check the Electron Vite docs.
Use the bytecodePlugin
from electron-vite
to enable it in the electron.vite.config.ts:
import { defineConfig, bytecodePlugin } from 'electron-vite'
export default defineConfig({
main: {
plugins: [tsconfigPaths, bytecodePlugin()]
},
preload: {
// Note: you will get the following warning using bytecodePlugin in the preload script in production build: "The vm module of Node.js is deprecated in the renderer process and will be removed", is up to you to keep bytecodePlugin here. Also, keep following the Electron Vite docs for more updates about this plugin!
plugins: [tsconfigPaths, bytecodePlugin()]
},
renderer: {
// ...
}
})
Also, sandbox
should be false
in webPreferences
for the windows you are using a preload script like:
const window = createWindow({
id: 'main',
webPreferences: {
preload: join(__dirname, '../preload/index.js'),
sandbox: false,
},
})