Skip to content

Named CSS variables usage, defineVars performance #676

Answered by nmn
BMCwebdev asked this question in Q&A
Discussion options

You must be logged in to vote

By switching to named CSS variables (using -- strings in defineVars) is having safely hashed names (no repeats) the only major feature I would be loosing?

Yes.

Does StyleX do tree shaking for defineVars ?

Not yet. But you probably run the output CSS file through a postcss plugin to strip out unused variables.

Do you see any drawbacks from using this pattern?

You're breaking the rules of variables. Don't do that. Put all the variables within a single defineVars if you want that convenience. Don't try to "re-export" variables. That's not supported.
Even with the -- variable names, things may work right now, but it's not a supported pattern and could break with a future update.

Somethi…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@BMCwebdev
Comment options

Answer selected by BMCwebdev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants