New BrowserWindow isn't loading in prod
See original GitHub issueI’m trying to open a new BrowserWindow, it works fine in yarn dev
, but in full release it just comes up as a white window that never does anything. I’ve tried using #/paths with the default router, and the solution here using react-router-dom with search props: https://github.com/electron-react-boilerplate/electron-react-boilerplate/issues/623
Presumably some Webpack config issue, which I have very little experience with, or I’m just flat out loading the wrong file path because of prod bundle wizardry.
Prerequisites
- [x ] Using yarn
- [x ] Using node 10.x
- [x ] Using an up-to-date
master
branch - [x ] Using latest version of devtools. See wiki for howto update
- For issue in production release, devtools output of
DEBUG_PROD=true yarn build && yarn start
- no output is given
Expected Behavior
Opening a new BrowserWindow from within a component in prod should work properly, as it does in dev.
Current Behavior
New BrowserWindow opens, but seems not to load any renderer process. Debug prod output shows console logs firing the event, but no logs from the process afterwards.
Possible Solution
Some prod Webpack config alterations I guess 🤷♂️
Steps to Reproduce (for bugs)
The code suggested here for the router: https://github.com/electron-react-boilerplate/electron-react-boilerplate/issues/623#issuecomment-333750155
Being called from a component like; this.windowObject = window.open(
file://${__dirname}/app.html?gallery);
Works in yarn dev, but not yarn start.
Alternatively, with no changes to the original router
window.open(
file://${__dirname}/app.html#/counter);
would also have the same effect.
Output of that file path in dev is: file://E:\Github\xx\app/app.html?counter
Vs in prod: file:////app.html?counter
If that would effect anything when bundled.
Context
Trying to open a new child window from a component, ended up here. This still launches a whole new React app which seems undesirable, but oh well. No intelligent changes to the core boilerplate.
Your Environment
- Node version : v10.15.2
- Version or Branch used : master/latest
- Operating System and version : Windows 7
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
The default is Electron 8 now, but I have the same issue. Console says “Not allowed to load local resource,” which is essentially a 404 (I get that on dev if I load some nonexistent path).
Complete code, works on dev but not prod:
I’ve tried with
nodeIntegration
false and true. Peeked at the packagedrenderer.prod.js
, no clues there. Frankly the docs should simply tell you how to open a local component page; just the above took me a lot of sifting through StackOverflow.when after build, __dirname is
/
, whatever I set nodeIntegration:true…