JSPM

  • Created
  • Published
  • Downloads 11426414
  • Score
    100M100P100Q228970F
  • License MIT

Merge CSS rules with PostCSS.

Package Exports

  • postcss-merge-rules

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (postcss-merge-rules) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

postcss-merge-rules Build Status NPM version Dependency Status

Merge CSS rules with PostCSS.

Install via npm:

npm install postcss-merge-rules --save

Example

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:

By declarations

a {
    color: blue;
    font-weight: bold
}

p {
    color: blue;
    font-weight: bold
}

Becomes:

a,p {
    color: blue;
    font-weight: bold
}

By selectors

a {
    color: blue
}

a {
    font-weight: bold
}

Becomes:

a {
    color: blue;
    font-weight: bold
}

By partial declarations

a {
    font-weight: bold
}

p {
    color: blue;
    font-weight: bold
}

Becomes:

a,p {
    font-weight: bold
}

p {
    color: blue
}

Contributing

Pull requests are welcome. If you add functionality, then please add unit tests to cover it.

License

MIT © Ben Briggs