PostCSS This plugin replace CSS classes by JSON like: { "className": "newName" }
From:
.button {
background: #0099cc;
}
.button .icon {
margin: 4px;
}
With:
// path/to/file.json
{
"button": "btn",
"icon": "_j2s"
}
To:
.btn {
background: #0099cc;
}
.btn ._j2s {
margin 4px;
}
const options = {
file: 'path/to/file.json'
}
postcss([ require('postcss-replace-bemclasses')(options) ])
See PostCSS docs for examples for your environment.