postcss / postcss-simple-vars

PostCSS plugin for Sass-like variables

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Removing CSS line if variable does not exist

jholt1 opened this issue · comments

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.

Nope. We didn’t have this feature.

What is your use case?

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.

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.

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