postcss / postcss-simple-vars

PostCSS plugin for Sass-like variables

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sass !default behaviour

sekoyo opened this issue · comments

Hi,

I was wondering if there's any intention or interest in adding a !default keyword to this plugin?

It's a powerful feature for theming meaning a component (e.g. one in node_modules) can declare variables with the !default keyword, and then even if the component is included AFTER overrides it will not override them (it uses the first definition of the variable):

$primary-color: blue;
$primary-color: green !default; // Ignored

It means theming can be done with more confidence without worrying that the base theme (default/white-label) won't accidentally override the branding theme.

PostCSS try to keep CSS simple and declarative. If you want complicated logic (like prefixes) you should do it in JS.

This is why I don't like !default - it force you to put logic to CSS and make it hard to read.

If you have use case, I can show you some other ways.