postcss / postcss-simple-vars

PostCSS plugin for Sass-like variables
MIT License
415 stars 36 forks source link

Removing CSS line if variable does not exist #110

Closed jholt1 closed 2 years ago

jholt1 commented 2 years ago

Is there a way to remove the line of CSS if the variable does not exist?

Was looking into using unknown option to return an empty string and use https://www.npmjs.com/package/postcss-discard-empty. However, so far, this does not work.

ai commented 2 years ago

Nope. We didn’t have this feature.

What is your use case?

jholt1 commented 2 years ago

We are creating design tokens that are imported to use as variables. Based on the use of the design tokens config and themes - not all the tokens will exist. When the token does not exist, it indicates the style is not required.

ai commented 2 years ago

In this case it will be easier to write a simple custom PostCSS plugin to clean this variables and run it before postcss-simple-vars.

But you can also send PR to this plugin.

jholt1 commented 2 years ago

Thanks @ai for the clarity, will give it a go