Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

images broken after building with electron-builder #19

Closed
lduros opened this issue Feb 22, 2018 · 7 comments
Closed

images broken after building with electron-builder #19

lduros opened this issue Feb 22, 2018 · 7 comments

Comments

@lduros
Copy link

lduros commented Feb 22, 2018

Hello,
This may not be directly an issue with this package, but whenever I use electron-builder and build a standalone electron app (dmg file, ...) everything works great for the React piece inside Electron except for the images. I can see them both in my public directory as well as in the build/ directory. However after debugging the standalone electron app, it's attempting to load the image from

file:///my-img-folder/my-img.png

while it should probably be something like this as a prod electron, I'm assuming:

file:///Applications/m-yapp.app/Contents/Resources/app.asar/build/my-img-folder/my-img.png

Has anyone seen this behavior as well? I'm thinking a variable in .env might be the solution here, but I'm not sure what it should be.

@lduros lduros changed the title images broken after using electron-builder images broken after building with electron-builder Feb 22, 2018
@csepulv
Copy link
Owner

csepulv commented Feb 22, 2018

I don't know how to fix this. In a quick search, I found this electron-react-boilerplate/electron-react-boilerplate#712, which describes a fix via a webpack config change. But that would require eject of the app.

I will see if i find anything else.

@lduros
Copy link
Author

lduros commented Feb 22, 2018

Thanks for looking into it, I'll update here if I can find a solution. I guess I could use hardcoded data-uris meanwhile for images. Also, it might be a possibility to eject only within the context of building the app with electron-builder.

@csepulv
Copy link
Owner

csepulv commented Feb 22, 2018

@thalessd
Copy link

thalessd commented Jun 3, 2019

If your using React, Electron and react-router-dom, change your react-router-dom "BrowserRouter" to "HashRouter".

@csepulv csepulv closed this as completed Dec 7, 2019
@kylelynchkurzawa
Copy link

@thalessd Thank you so much!! The switch from BrowserRouter to HashRouter solved my image issues too!

@claytonfbell
Copy link

If your using React, Electron and react-router-dom, change your react-router-dom "BrowserRouter" to "HashRouter".

This probably saved me sooo much time, thank you!

@RafaelDamiani
Copy link

If your using React, Electron and react-router-dom, change your react-router-dom "BrowserRouter" to "HashRouter".

Amazing man, thank u so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants