MadLittleMods / postcss-css-variables

PostCSS plugin to transform CSS Custom Properties(CSS variables) syntax into a static representation
https://madlittlemods.github.io/postcss-css-variables/playground/
Other
536 stars 62 forks source link

Too many empty :root in output when passing variables #119

Open pfrankov opened 4 years ago

pfrankov commented 4 years ago

Here is an issue: There is a test fixture called test/fixtures/js-defined-preserve-injected.css

.box1 {
    width: var(--js-defined1);
    height: var(--js-defined2);
    background: var(--js-defined-no-prefix);
}

With an output in test/fixtures/js-defined-preserve-injected.expected.css

:root {
}
:root {
}
:root {
}
:root {
}

.box1 {
    width: 75px;
    width: var(--js-defined1);
    height: 80px;
    height: var(--js-defined2);
    background: #ff0000;
    background: var(--js-defined-no-prefix);
}

I'd say that these duplicating :roots are not very useful for any purpose and must be removed from the output.

What do you think?

MadLittleMods commented 4 years ago

Related to https://github.com/MadLittleMods/postcss-css-variables/issues/89

It would be nice if they were not in the output. PR welcome to fix it.