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

Not working when variables file is @import -ed #18

Closed radubrehar closed 8 years ago

radubrehar commented 8 years ago

I have variables in one file, let's call it 'vars.css'

In 'main.css' I try to @import './vars.css'and use variables. This fails and renders undefined. If I define variables in the same file where I use them, it's working.

vars.css

:root {
  --red: #D85743;
}

main.css

@import './vars.css'; /*or @import url('./vars.css')*/

.red {
  color: var(--red);
}
MadLittleMods commented 8 years ago

@radubrehar Are you running postcss-import before postcss-css-variables (plugin order)?

radubrehar commented 8 years ago

Is it necessary? I mean I don't want to inline all my css files that I @import

MadLittleMods commented 8 years ago

@radubrehar Do you know of another plugin that can handle declarations that are in a @import'ed file? I am curious to see what they are doing.

Running postcss-import before postcss-css-variables is necessary now because we get the map of variables from the rules and declarations passed in.

radubrehar commented 8 years ago

Thanks, it works!