I have a file variables.css
with CSS variables inside a :root{}
Right now each time I need to use it in another .css
file I use:
@import './path/to/variables.css'
.
I want to know if there is a way to have variables.css
available globally without having to import it every single time I need it.
I tried to use the option customProperties
on cssnext
plugin, but it gives an error compiling css to a js object...
I'm using React
with webpack 1
and as postcss plugins I have import
, mixins
, cssnext
and nested
.
Thanks
As far as I understand, no, but you can make your life easier. In your config for import, set the path, such as:
cssImport({ path: './src' })
And assuming your
variables.css
is insrc/variables.css
, you can simply do:@import 'variables';
instead of dot walking back up the tree to find the right spot.