mercredi 30 juin 2021

How to add preload script to ElectronForge Webpack project?

I'm creating a project with ElectronForge by using "webpack" template. Now, I want to add the preload script into it. I've used this in my main.js:

webPreferences: {
preload: path.join(__dirname, 'preload.js')
}

But it doesn't work. Then I used:

webPreferences: {
preload: MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY
}

but nothing works. I have also added this in my package.json:

"entryPoints": [
{
"html": "./src/index.html",
"js": "./src/renderer.js",
"name": "main_window",
"preload": {
"js": "./src/preload.js"
}
}
]

But I'm unable to identify that what else I have to do? Do I have to include the references to preload.js somewhere else too? If yes, then where? Can someone please guide me step by step that how to use the preload script with webpack template in ElectronForge? I'll be very thankful. I searched a lot, but I couldn't find the way to use preload script.




Aucun commentaire:

Enregistrer un commentaire