Better solution for electron <base> url (or just document it)
See original GitHub issueHi,
I am trying to get my app running with Electron but no luck. When building this for iOS the iOS Simulator can start the app without problems.
For some reason it cannot load the app.js
and app.css
. I use the dist
dir and configured this in my capacitor.config.json
{
"appId": "com.ex.ample.com",
"appName": "Example",
"bundledWebRuntime": false,
"webDir": "dist"
}
My npm run build
and npx cap copy
commands run fine without any errors. I use Fedora 26, if that matters 😉
Any idea?
Thanks!
Issue Analytics
- State:
- Created 5 years ago
- Comments:27 (10 by maintainers)
Top Results From Across the Web
Common Configuration - electron-builder
Common Configuration · in the package.json file of your project using the build key on the top level: "build": { "appId": "com.example.app" }...
Read more >BrowserWindow | Electron
The BrowserWindow class exposes various ways to modify the look and behavior of your app's windows. For more details, see the Window Customization...
Read more >Building for Production - Vite
BASE_URL variable which will be the public base path. ... It is a good strategy for some SPAs, but it is hard to...
Read more >When packaging up my Angular 2 Electron App, routes no ...
When I run my Angular 2 Electron project with ng build or ng serve it works 100% all the routers and everything just...
Read more >Building a Vue 3 Desktop App with Vite and Electron - LearnVue
At first, it may seem like we already have our main.js and index.html files, but those are the ones we need for Vite...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
UPDATE:
I now have working static paths to my JS/CSS etc in CRA + Capacitor + Electron.
Having scoured the CRA repo for static asset bugs & fixes, this is the solution that works for me:
<base href="./">
from.\public\index.html
as it does nothing."homepage": "."
to.\package.json
in root directory. Therefore,npm run build
followed bynpx cap copy
ensures that all the static asset paths in.\electron\app\index.html
are nowsrc="./static/"
.Related to https://github.com/ionic-team/capacitor/issues/693.
@mlynch maybe we should also use a web server as on iOS and Android to serve the files instead of serving from file:?