Postcss plugin to safely remove the unused CSS var from your styles
npm install postcss-unused-var --save-devRefer the PostCSS Documentation for using this plugin.
:root {
--root-var-color: red;
}
#div1 {
--main-txt-color: blue;
--main-padding: 15px;
--main-bg-color: coral;
background-color: var(--main-bg-color);
}:root {
--root-var-color: red;
}
#div1 {
--main-bg-color: coral;
background-color: var(--main-bg-color);
}Not removing the un-used variables from
:rootas they are available acroos the site and can be access in other stylesheet as well. So they might have used in other stylesheet so its not safe to remove them