postcss-merge-rules
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

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

/postcss-merge-rules/

    Package Sidebar

    Install

    npm i postcss-merge-rules@1.1.0

    Version

    1.1.0

    License

    MIT

    Last publish

    Collaborators

    • beneb
    • trysound
    • ludovicofischer
    • ai
    • chriseppstein
    • andyjansson
    • evilebottnawi
    • cssnano-bot