Ilja Ilja - 1 year ago 153
CSS Question

Using css next variables globaly

I have postcss parser set up with and am trying to figure out a way to set up a

file to contain all my theme settings.

So far
looks like this with a couple of vars

:root {
--color-white: #FFF;
--color-black: #000;

I than import it into my other files where I want to use these variables, so
@import './variables.css'
or similar and then use it in that file like
background-color: var(--color-white)
for example, however I get follwoing warning:

variable '--color-white' is undefined and used without a fallback

Answer Source

You can try to install postcss import

$ npm install postcss-import

Check this post for more details how to install.

EDIT Using postcss-import solved the issue, however there are currently issues with latest version, use v 7.x for stability

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download