Resources from static/media are not resolvable after package
See original GitHub issue- Version: 21.2.0
- Target: Linux deb
I am using CRA to build the app and getting such build structure:
After building the project with electron, the application does not substitute the correct path to the files from static/media
and does not find them.
./static/media/logo.4c2ab132.svg
-> file:///static/media/logo.4c2ab132.svg
.
Although the paths for the files in static/css
and static/js
are defined correctly (full path to app.asar).
./static/media/logo.4c2ab132.svg
-> file:///home/user/path/to/app.asar/build/static/css/main.a20d4a01.chunk.css
.
In the final index.html all this file paths are relative.
What is the problem?
Issue Analytics
- State:
- Created 4 years ago
- Comments:18
Top Results From Across the Web
Spring boot app does not serve static resources after ...
Controllers RequestMappings are working fine, problems are only with the static resources. For what it's worth, it's usual with Boot to simply ...
Read more >2053169 – verify-api-int-resolvable throws "error
Bug 2053169 - verify-api-int-resolvable throws "error: You must be logged in to the server (Unauthorized)" after rebooting masters with a future date.
Read more >DNS Requirements for the vCenter Server Appliance
If you plan to use an FQDN for the appliance system name, you must verify that the FQDN is resolvable by a DNS...
Read more >What is the meaning of error: 'Unable to resolve host name' or ...
Once you enter the hostname by using the command prompt, following error ... If the domain is showing as active but not working,...
Read more >What is Amazon Route 53 Resolver?
If you have workloads that leverage both VPCs and on-premises resources, ... The following diagram shows hybrid DNS resolution with Resolver endpoints.
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 FreeTop 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
Top GitHub Comments
I also had this problem, the files in ‘build/static/media/*.png’ (and gifs too). They were not found. solution: note: I’m using react and building with electron https://stackoverflow.com/questions/45178195/image-assets-not-found-in-packaged-electron-app-angular4-and-webpack Only add
<base href="./">
in ‘public/index.html’I just manually placed the files in a public folder and after packaging they are still unavailable, which means the problem is not related to the webpack or CRA. Although all these files are present in app.asar and if you manually set the correct path, the file will be available.
Maybe
FileSet.from
/FileSet.to
or manipulating withfiles
andbuildResources
inpackage.json
is close to the right solution but I didn’t succeed with it.I found electron-serve for serving static files in electron. But I did not understand how it works because I did not have time to use it.
But I found a solution for myself. I used protocol.interceptFileProtocol() for modifying paths to requested resources. Example of usage on stackoverflow
@srepollock, I think it’s suitable for you too. Here is needed part of my code in
main.js
:I feel it more like workaround, but seems it’s appropriate solution in context of electron applications.