How to get source maps to work with Electron?

I am developing a cross-platform application, and part of that is using @capacitor-community/electron for desktop.
The build and export itself works fine, but I cannot get the source maps to work.

I am updating the electron build like this:
ionic cap sync

And then run it by going to the electron directory and:
npm run build && electron ./

It seems to me that the .map files are just blindly copied from root/build/static/js to root/electron/app/static/js.
Naturally, the paths inside of the .map files won’t work in that location, as an additional “…/” (or even “…/…/”?) would be required.

The errors all look like this:

devtools failed to load sourcemap could not load content for “capacitor-electron://-/static/js/16.45739f90.chunk.js.map”

Is there a way to tell ionic (or capacitor) to change the paths so that the source maps will work with the electron target?

1 Like