postcss-merge-rules
Merge CSS rules with PostCSS.
Install via npm:
npm install postcss-merge-rules --save
var postcss = require('postcss');
var mergeRules = require('postcss-merge-rules');
var css = 'a{color:blue}a{font-weight:bold}';
console.log(postcss(mergeRules()).process(css).css);
// => 'a{color:blue;font-weight:bold}'
This module will attempt to merge adjacent CSS rules:
a {
color: blue;
font-weight: bold
}
p {
color: blue;
font-weight: bold
}
Becomes:
a,p {
color: blue;
font-weight: bold
}
a {
color: blue
}
a {
font-weight: bold
}
Becomes:
a {
color: blue;
font-weight: bold
}
a {
font-weight: bold
}
p {
color: blue;
font-weight: bold
}
Becomes:
a,p {
font-weight: bold
}
p {
color: blue
}
Pull requests are welcome. If you add functionality, then please add unit tests to cover it.
MIT © Ben Briggs