PostCSS plugin share variables between different css files with scope. This implementation may replace values variables in css-modules and allow using native css variables syntax.
/* vars.css */
:root {
--root-width: 25px;
}
@shared --root-width from "./vars.css";
.foo {
width: var(--root-width);
height: calc(var(--root-width) * 2);
}
:root {
--root-width-<md5_hash>: 25px;
}
.foo {
width: var(--root-width-<md5_hash>);
height: calc(var(--root-width-<md5_hash>) * 2);
}
postcss([ require('postcss-shared-options') ])
See PostCSS docs for examples for your environment.