Open mmahdigh opened 3 years ago
JSS is automatically adding the styles used on each page in the head. What you are looking for looks much more like using plain CSS structured as you want in separate files.
Maybe phrasing the question a bit differently. Can you share what is the problem you are trying to solve?
JSS is automatically adding the styles used on each page in the head. What you are looking for looks much more like using plain CSS structured as you want in separate files.
Maybe phrasing the question a bit differently. Can you share what is the problem you are trying to solve?
Hey Marija
Honestly it's a requirement set by our SEO team. I haven't spoken with them but I guess maybe they're trying to trim some kilobytes.
I'm basically looking for something like what Linaria offers, creating external CSS files in build time and serving the CSS externally rather than adding them to the head.
Is this what your looking for? https://material-ui.com/guides/server-rendering/
Is this what your looking for? https://material-ui.com/guides/server-rendering/
Unfortunately, no. This injects styles directly in the head resulting in a larger document size. We're looking for a way to take those injected styles and statically extract them into CSS files that can be served instead. While this is slightly harmful for FCP, it makes some crawlers (specifically Bingbot) happier.
The guide shows how to render the styles server side - you can save them to wherever you'd like.
The guide shows how to render the styles server side - you can save them to wherever you'd like.
Our understanding gap isn't how to get the styles needed during the server render. The understanding gap is how to serve that content statically.
Same as any css file, although you'll need to remove them once react loads (see the link above)
Same as any css file?
Great! Could you share how to extract this content statically into a CSS file?
See the link above, which covers a similar use case.
I use @material-ui/styles in a SSR project and the problem is each page CSS styles are added internally.
Are there any ways that CSS styles be used externally (i.e. in separate CSS files)?