question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Better solution for electron <base> url (or just document it)

See original GitHub issue

Hi,

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.

image

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:closed
  • Created 5 years ago
  • Comments:27 (10 by maintainers)

github_iconTop GitHub Comments

20reactions
bashercommented, May 28, 2019

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:

  1. Removed <base href="./"> from .\public\index.html as it does nothing.
  2. Added "homepage": "." to .\package.json in root directory. Therefore, npm run build followed by npx cap copy ensures that all the static asset paths in .\electron\app\index.html are now src="./static/".
9reactions
jcesarmobilecommented, Jul 31, 2018

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:?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found