- When I bundle my html file with webpack and load it in Electron-renderer, the script does not load correctly. Even though I am certain that I am loading the correct file, as it loads when I remove the script tag placed by html-webpack-plugin in the compiled 'index.html.'
My experiments with webpack-dev-server have yielded different results based on the setup:
If I run webpack-dev-server first and then start Electron from a separate bash instance, I always end up with an empty window displaying nothing loaded.
However, if I launch webpack-dev-server and electron from the same bash instance using a custom start script,
package.json
{
"scripts": {
"start": "./start.sh"
}
}
start.sh
#!/usr/bin/env bash
trap 'kill $(jobs -p)' EXIT
npm run serve &
npm run start:electron:server &
wait
In this setup, two scenarios unfold due to the absence of any timeout:
2.1 The DOM remains unpopulated although the bundled script is loaded successfully.
2.2 Alternatively, the DOM may be populated and the script is loaded, giving a false impression that all is well. However, any changes to the code result in empty sources being reloaded by Electron.
Furthermore, closing Electron via standard methods becomes impossible after the webpack-dev-server starts and electron is listening, likely due to an open websocket connection.
The issue might reside in the webpack configurations, specifically with how Electron attempts to load content from both the file and server simultaneously without success. This inconsistency in loading behavior poses a challenge in identifying the root cause within the webpack settings.