You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the PostCSS plugin, I was collecting the names and values of variables, as well as the declarations where the actual variables are being used, and then substituting them all at once at the end:
I tried a similar approach in Lightning CSS's visitor as I did with the PostCSS plugin (it's not exactly the same due to Lightning CSS visitors modifying CSS by returning values from functions):
But Variable() is called before Declaration(), so the substitution does not work. Of course, I am aware that it would work if the variables were defined before their actual use. However, I cannot arbitrarily control the order because I am using framework like Vite.
Could someone give me any ideas or hints on which visitor to use for this?
Thank you for reading my long question.
P.S. Lightning CSS is really awesome! Big thanks to the maintainers and contributors!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I want to substitute specific CSS variables (like
--space-n
).Example:
In the PostCSS plugin, I was collecting the names and values of variables, as well as the declarations where the actual variables are being used, and then substituting them all at once at the end:
I tried a similar approach in Lightning CSS's visitor as I did with the PostCSS plugin (it's not exactly the same due to Lightning CSS visitors modifying CSS by returning values from functions):
But
Variable()
is called beforeDeclaration()
, so the substitution does not work. Of course, I am aware that it would work if the variables were defined before their actual use. However, I cannot arbitrarily control the order because I am using framework like Vite.Could someone give me any ideas or hints on which visitor to use for this?
Thank you for reading my long question.
P.S. Lightning CSS is really awesome! Big thanks to the maintainers and contributors!
Beta Was this translation helpful? Give feedback.
All reactions