Closed oleersoy closed 8 years ago
This is as expected. You need to run postcss-import
before postcss-css-variables
to get desired results.
var output = postcss([
importCSS(),
cssvariables( /*options*/ )
])
.process(mycss)
.css;
Which will make your original example look like the following when it reaches postcss-css-variables
:root {
--varB: 'valueB';
}
:root {
--varA: var(--varB);
}
h1 {
color: var(--varA);
}
Ah - Super - Thanks!
Hi,
I have a CSS file like this:
And in
cssB.css
:If I run this through the following script:
I get this as a result:
So the original
cssA.css :root
selector is replaced by the:root
selector fromcssB.css
. Is that supposed to happen? Since suitcss theme uses multiple:root
selectors in a single file, I assumed that this was OK?I tried changing cssA.css to look like this:
When I run
process.js
I now get this as a result:So it works with multiple
:root
selectors in the same file, although they are not removed once the variables are resolved.I did one more experiment. It looks like this:
In this case the result is:
So the
@import
statement only replaces the first root selector...Ole