styled-components / styled-components

Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress 💅
https://styled-components.com
MIT License
40.11k stars 2.48k forks source link

Ssr not picking up styled components from an npm package #4296

Open Pixelatex opened 2 weeks ago

Pixelatex commented 2 weeks ago

I am serverside rendering a web app. (Using vite) Styled components works for any "native" components but when I import a simple button or so from an external component library I built, it will only pick up the styles for this on the client side.

I noticed that when I added the displayname true option to the babel plugin that only my native components were showing the names on the server.

Logging the initial style tags collected by the server stylesheet also doesn't show any component library classnames.

This leads me to think that somehow my serverside rendering is incapable of picking up the components.

What I tried:

Does anyone have a vague idea what I am missing for this to work?

quantizor commented 1 week ago

Are you certain that there is only one copy of styled-components being loaded?