bennymeg / nx-electron

Electron schematics for nrwl nx platform
Apache License 2.0
309 stars 82 forks source link

Packaged Electron-React app renders a blank page #212

Closed VladislavMaksimov closed 1 year ago

VladislavMaksimov commented 1 year ago

Hello, I use nx-electron with React and package a simple app with the Nx's welcome page. It works well in dev mode, but after packaging, the app renders a blank page.

My main Electron app and renderer React app are in a client folder. After generating the Electron app with nx-electron I changed a <base href="/" /> to <base href="./" /> in index.html of the React app, and made some changes in project.json:

from

"package": {
      ...
      "options": {
        "name": "client-main",
        ...
      }
},

to

"package": {
      ...
      "options": {
        "name": "client/main",
        ...
      }
},

because I had an error

ENOENT: no such file or directory, open 'C:\...\my-project\dist\apps\client-main\index.js'

Before I changed a <base href="/" /> I had an error connected with paths after packaging; now I don't have any errors, but nothing is being rendered either.

Also tried to change a baseHref option in the Electron app's project.json, but it didn't change anything. After that, I added a HashRouter to the React app (although I have only one page in it and don't need the router), but it also didn't help.

What should I do?

My OS and tools versions

VladislavMaksimov commented 1 year ago

Also tried to change the version of Nx to 14.0.2 and to change the build path of the Electron app to client/main, but none of that worked.

bennymeg commented 1 year ago

All the aplicatioins should reside inside the apps folder. Nesting is not supported.

VladislavMaksimov commented 1 year ago

All the aplicatioins should reside inside the apps folder. Nesting is not supported.

Thanks! Thought that nesting is supported and even required because for some reason there is a directory input when you use the Nx console and it's being rendered as a required field.

image