-
Is there a way to change the name of the generated classnames and css variables? I want to apply my own hash/name/prefix to classnames and css variables and haven't found it in the docs. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 10 replies
-
Currently there is no way to do this. What problem do you need to solve that isn't ideal with the current solution? |
Beta Was this translation helpful? Give feedback.
-
My team is also interested in this feature, mostly for future-proofing. Imagine some day we stop using our component system or even JS altogether but we still want to use the CSS styles. It would be pretty cumbersome with the current way classes are named. This is the "use vanilla-extract to make your own tailwind" use case. @markdalgleish |
Beta Was this translation helpful? Give feedback.
-
This has actually become problematic for a project I'm on that leverages Webpack Module Federation. We have a component library using vanilla-extract, and the parent and child modules may need different versions of that library. Because of the inability to change classnames, classes can often intersect between different versions and result in bugs or unexpected behaviors when the modules don't share the same version of the lib. |
Beta Was this translation helpful? Give feedback.
-
Is there a way we could use a decorator in the code to name the class? Or a comment with metadata specific to vanilla-extract? |
Beta Was this translation helpful? Give feedback.
-
To add another usecase: we are planning on using VE in a Microfrontend environment, so multiple UIs will generate their own css file. To prevent classes from colliding it would be necessary to add a prefix to classes for each microfontend. |
Beta Was this translation helpful? Give feedback.
-
I currently have a usecase for this functionality as well. We basically have 2 different workflows:
I though I might give VE a go to develop the css framework as it would make managing the codebase much easier and a bit easier to update. My current workflow is using vite to ingest the scss (many @use/@forward being used), and I get a nice bundled css file that is easy to read/use for the vanilla html/css projects. However, as it stands, the class names/hashes are just too hard to remember/utilize. I could use VE for the second item in my list, but then I would need to also develop a standalone solution for the first which isn't feasible. |
Beta Was this translation helpful? Give feedback.
-
Since I found this Q&A and discussion that's not answered, if anyone stubbles on this - it is now possible to change hash identifiers: #1160 |
Beta Was this translation helpful? Give feedback.
Since I found this Q&A and discussion that's not answered, if anyone stubbles on this - it is now possible to change hash identifiers: #1160