truein a given renderer's
BrowserWindowconstructor, you'll need to set the same
nodeIntegrationvalue in the corresponding Webpack plugin renderer's configuration:
devContentSecurityPolicyin your Forge Webpack plugin configuration (note that it is separate from the main and renderer configuration):
'unsafe-eval'will cause Electron itself to trigger a warning in the DevTools console about having that value enabled, which is usually fine so long as you do not set that value in production.
mainentry in your
package.jsonfile needs to point at
preloadpaths need to reference the entry points' magic global variables that this plugin will define for you. Each entry point has two globals defined: one suffixed with
_WEBPACK_ENTRY, and the other suffixed with
_PRELOAD_WEBPACK_ENTRY. These point to the paths for your renderer entry point and your preload script path, respectively. In the case of the
main_windowentry point in the earlier example, the global variables will be named
MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY. An example of how to use them is given below:
module.rulesconfiguration in your Webpack config. Ensure you install both
@vercel/webpack-asset-relocator-loaderas development dependencies.
rsin the console you launched
electron-forgefrom and we will restart your app for you with the new main process code.
webpack-dev-serverinstances to power your renderer processes, in prod we just build the static files. Assuming you use the globals we explained in Project Setup, everything should Just Work™ when your app is packaged.
react-routerto do virtual routing in your app, you will need to ensure you use a history method that is not based on the browser history APIs. Browser history will work in development but not in production, as your code will be loaded from the filesystem, not a webserver. In the
react-routercase, you should use the
MemoryRouterto make everything work.