PostCSS This plugin remove CSS rules that are not contained in JSON like: ['.button', '.someSelector']
From:
.button {
background: #0099cc;
}
.icon {
padding: 8px;
}
.button .icon {
margin: 4px;
}
With:
// path/to/file.json
['.button', 'someSelector']
To:
.button {
background: #0099cc;
}
const options = {
file: 'path/to/file.json'
}
postcss([ require('postcss-remove-unused')(options) ])
See PostCSS docs for examples for your environment.