i’m trying to build from scratch an app with ionic-react & electronjs, but following official "get started"guide https://capacitor.ionicframework.com/
electron main page is blank and not correctly shown.
electron apps are served from file protocol, so they need to be built in a different way.
I’ve made it work by adding "homepage": "." in the package.json and removing the <base href="/" /> in index.html or changing it to <base href="%PUBLIC_URL%/">
It took me several hours to find this solution. I will add this clarification:
remove from ./electron/app/index.html the tag <base href="/" />
add this property to ./electron/package.json: "homepage": "."
@jcesarmobile I would observe that it is the capacitor that is creating the package.json file. So it does know something: a) it is electron and b) the files are served from file protocol. So it could at least add the homepage value. The change to the base href could at least be documented.
The homepage is a React thing, and for React apps you have to remove the base href, while in Angular apps you have to change it to “./”
Capacitor is framework agnostic, and doesn’t know if you use React or Angular or something else, and can’t make assumptions.
Those are not Capacitor bugs, Capacitor just provides plugin APIs for your electron app, but you still need to know electron and the framework configurations docs needed to work in electron. And if you don’t know them, you should be able to search them on the framework doc websites, because as I said, they depend on the framework you use, not on Capacitor.