JSPM

  • Created
  • Published
  • Downloads 11627980
  • Score
    100M100P100Q248447F
  • License MIT

Discard duplicate rules in your CSS files with PostCSS.

Package Exports

  • postcss-discard-duplicates

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-discard-duplicates) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

postcss-discard-duplicates Build Status NPM version Dependency Status

Discard duplicate rules in your CSS files with PostCSS.

Install via npm:

npm install postcss-discard-duplicates --save

Example

var postcss = require('postcss')
var duplicates = require('postcss-discard-duplicates');

var css = 'h1{margin:0 auto;margin:0 auto}h1{margin:0 auto}';
console.log(postcss(duplicates()).process(css).css);

// => 'h1{margin:0 auto}'

This module will remove all duplicate rules from your stylesheets. It works on at rules, normal rules and declarations. Note that this module does not have any responsibility for normalising declarations, selectors or whitespace, so that it considers these two rules to be different:

h1, h2 {
    color: blue;
}

h2, h1 {
    color: blue;
}

It has to assume that your rules have already been transformed by another processor, otherwise it would be responsible for too many things.

Contributing

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

License

MIT © Ben Briggs