Comments (11)
One more:
Using this code hardcoded in index.jsx it works on dev correctly.
But after compile when running in prod env, it looks like it look for the favicons pngs in the wrong folder ie:
href="/./assets/6f9927a38c643c8f5fcac15a6c15aa04.png
instead of:
href="/assets/./assets/6f9927a38c643c8f5fcac15a6c15aa04.png
(it should be with assets twice i think).
It only happen for the favicons, for other images it works correctly.
(The files exists in the filesystem under build/server/assets both the favicons and the regular images)
(i remember something similar before a month when running on dev which looks like it search something in the prod url)
Any idea?
from apollo-universal-starter-kit.
Hi @GiladShoham
Yes, properly supporting favicon's would be nice I think.
from apollo-universal-starter-kit.
I continue investigating the problem with my favicon and found:
- in the index.jsx there is check if it's dev or not, if not it will add /assets and find the correct url with the assetMap
- most of the images like the logo is found both under build/server/assets and build/client/assets and therefor found in the assets.json.
- the favicon is found only on build/server/assets so it's not in the assetMap. so i can't use this same technics.
I consider adding ManifestPlugin to server plugins to create another assetMap but it looks very wrong for me, and it's kind of workaround instead take care the real problem.
Is there any reason why other pngs are both in client and server and those favicon not?
Does adding assetMap for the server assets is reasonable solution?
Thanks.
from apollo-universal-starter-kit.
Is there any reason why other pngs are both in client and server and those favicon not?
I'm not sure what you are talking about, when I run 'npm run build' all the images are placed into build/client/assets
from apollo-universal-starter-kit.
@GiladShoham Ah, I understand you now. You are talking about image files that are placed into build/server
, during development phase, I will look into this, whether it is still needed...
from apollo-universal-starter-kit.
@GiladShoham I think all your concerns raised in this ticket should be resolved by commit:
e87cf75
from apollo-universal-starter-kit.
@Vlasenko
Thank you.
It's still needed.
Meantime i did some workaround.
I create new loader for the favicon files, without hashing in the name.
Then i faced another problem (when put it in the head on html.jsx) it didn't sent to the client.
So i required them as well in the body in hidden div (which is really bad solution), so when reference them in the link href in the head i found them.
By the way, here is a great article about favicons and web pack.
(it didn't worked very well for me exactly like this, it did create the files in the output, but still didn't sent to the client without the workaround).
And later i decided to move it to dedicated loader in the config.
from apollo-universal-starter-kit.
@GiladShoham
Yes, I'm aware, that this can be tricky. I believe I have implemented it the proper way in the commit:
e87cf75
As in that article I use require.context as well to require all the favicon images and favicon metadata from src/assets
folder as specified in the link you have posted (by the way you can put other images into this folder and subfolders inside this folder and they will appear in assetMap with hash from their contents in the name). But above that I also use hashing on favicon files as I do for all the other image assets, so long term caching is done better then described in the link you posted - e.g. when underlying icon contents change - the name will also change, because hash from file contents changes.
from apollo-universal-starter-kit.
Looks great!
I'll check it soon.
I think it will be better to copy the favicon.ico to the root as well (without hashing) because some browsers are looking for this exact file in the root by default.
from apollo-universal-starter-kit.
@GiladShoham Yes, I think you are right. I have moved all assets into root URL and added exception for favicon.ico to not have hash in its name, please see commit:
9c3ed91
from apollo-universal-starter-kit.
@Vlasenko
Thanks!
I'll merge it to my project in few days.
from apollo-universal-starter-kit.
Related Issues (20)
- Multi Config Setup HOT 2
- Can't fully install dependencies after fresh download - expo-yarn-workspace postinstall fails HOT 4
- lerna stdout maxBuffer exceeded HOT 7
- [Question] Are there any plans to shift to any other package manager since lerna is no longer properly maintained. HOT 5
- Unable to perform a full page reload on edit post page in React Client. HOT 2
- Tests fail after clean installation
- feedback
- Update dependency react-navigation HOT 1
- How can i connect it with my Hasura database?
- Plans to upgrade to webpack 5 HOT 3
- Fail to build on a clean Fedora 33 installation
- Expo Go Android will not run. Says wrong sdk version of expo HOT 1
- New @server app dependencies install error (ambiguous syntax error)
- Standalone use
- master does not work
- Upgrade expo to latest SDK HOT 6
- Setting i18n debug to true reveals several potential issues
- Router is not worked ! HOT 6
- ..
- Demo app link on the readme file not working HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apollo-universal-starter-kit.