Using styled-jsx within Vite #6136
Replies: 3 comments 5 replies
-
Were you able to figure this out? I've tried adding |
Beta Was this translation helpful? Give feedback.
-
@axerivant funny, while true it would solve issues, it really doesn't address this specific issue and obviously moving a big react code-base to svelte is not an easy decision. @colindunn109 I too decided to abandon it and use CSS Modules, thanks, which vite out of the box handles. Even the emotion team has moved away from CSS-in-JS as I recall. It has it merits and the colocation is fantastic, but tooling always seems to crop up with issues. CSS Modules is the next closest thing. As mentioned |
Beta Was this translation helpful? Give feedback.
-
I think I found a reasonable solution, |
Beta Was this translation helpful? Give feedback.
-
Hey everyone!
I've been working on porting an existing project that leverages styled-jsx into a new project that I will be using Vite for.
The issue is, whenever I render out a component, I am thrown the following error:

this error means that styled-jsx didn't transpile your code at all therefore the style element is rendered as regular html and jsx is an invalid prop for it. More on that here.
The reason being is in order to leverage styled-jsx you need to pull it into you babel config.
I thought it would be simple to just pull the styled-jsx file into my vite.config but I am having no luck, and instead getting an error whenever I try an introduce that plugin into Vite.
I am aware there are alternatives to using styled-jsx, however the codebase that is being ported is very large, and rethinking how to structure our css would be a massive amount of lift.
Does anyone have any ideas? Does Vite need a separate plugin for styled-jsx for this to work?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions