Reputation: 3664
We have an electron app and want to load the renderer bundle using loadUrl()
.
win=new BrowserWindow({ /* ... */ })
win.loadURL(`file://${path.join(__dirname, '../../render/build/index.html')}`);
Inside the html file, we load the React Bundle
<script type="text/javascript" src="/js/app-my-hash.bundle.js"></script>
However, as expected, the file is not found, since, I guess, I need to set the root of the project somehow. I get this error
Failed to load resource: net::ERR_FILE_NOT_FOUND
What setting am I missing on the electron side (or webpack side) to get this working?
Upvotes: 2
Views: 4986
Reputation: 1712
Another approach to add relative path without manual update in index.html is by including,
homepage property in package.json.
For an example,
{
"name": "electron-project",
"homepage": "./", # Add this line
#.... all remaining properties
}
Upvotes: 3
Reputation: 1032
Use relative URL, like: src="js/app-my-hash.bundle.js"
or src="./js/app-my-hash.bundle.js"
Upvotes: 2