postcss-discard-duplicates
Discard duplicate rules in your CSS files with PostCSS.
Last updated 2 months ago by GitHub Actions .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install postcss-discard-duplicates 
SYNC missed versions from official npm registry.

postcss-discard-duplicates

Discard duplicate rules in your CSS files with PostCSS.

Install

With npm do:

npm install postcss-discard-duplicates --save

Example

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.

Input

h1 {
    margin: 0 auto;
    margin: 0 auto
}

h1 {
    margin: 0 auto
}

Output

h1 {
    margin: 0 auto
}

Sibling conditional blocks

The module removes a declaration from an earlier @media, @supports, @container or named @layer block when a later sibling block with the same name and parameters repeats it. The module keeps a @layer block, even if it is empty, because the first appearance of a layer determines the layer order. For the same reason it keeps every @import, since the imported style sheet may declare layers.

@media (min-width: 768px) {
    .a { top: 0 }
    .b { color: red }
}

@media (min-width: 768px) {
    .a { top: 0 }
}

becomes

@media (min-width: 768px) {
    .b { color: red }
}

@media (min-width: 768px) {
    .a { top: 0 }
}

Usage

See the PostCSS documentation for examples for your environment.

Contributors

See CONTRIBUTORS.md.

License

MIT © Ben Briggs

Current Tags

  • 9.0.7                                ...           latest (2 months ago)
  • 5.0.0-rc.2                                ...           next (6 years ago)
  • 4.0.0-nightly.2020.2.6                                ...           nightly (6 years ago)

66 Versions

  • 9.0.7                                ...           2 months ago
  • 9.0.6                                ...           2 months ago
  • 9.0.5                                ...           2 months ago
  • 9.0.4                                ...           2 months ago
  • 9.0.3                                ...           2 months ago
  • 9.0.2                                ...           3 months ago
  • 9.0.1                                ...           3 months ago
  • 9.0.0                                ...           3 months ago
  • 8.0.4                                ...           3 months ago
  • 8.0.3                                ...           4 months ago
  • 8.0.2                                ...           4 months ago
  • 8.0.1                                ...           6 months ago
  • 8.0.0                                ...           7 months ago
  • 7.0.4                                ...           7 months ago
  • 7.0.3                                ...           7 months ago
  • 7.0.2                                ...           2 years ago
  • 7.0.1                                ...           2 years ago
  • 7.0.0                                ...           3 years ago
  • 6.0.3                                ...           3 years ago
  • 6.0.2                                ...           3 years ago
  • 6.0.1                                ...           3 years ago
  • 6.0.0                                ...           4 years ago
  • 5.1.0                                ...           5 years ago
  • 5.0.3                                ...           5 years ago
  • 5.0.2                                ...           5 years ago
  • 5.0.1                                ...           6 years ago
  • 5.0.0                                ...           6 years ago
  • 5.0.0-rc.2                                ...           6 years ago
  • 5.0.0-rc.1                                ...           6 years ago
  • 5.0.0-rc.0                                ...           6 years ago
  • 4.0.0-nightly.2020.2.6                                ...           6 years ago
  • 4.0.0-nightly.2020.1.11                                ...           6 years ago
  • 4.0.0-nightly.2020.1.9                                ...           6 years ago
  • 4.0.0-nightly.2020.10.20                                ...           6 years ago
  • 4.0.0-nightly.2020.9.9                                ...           6 years ago
  • 4.0.0-nightly.2020.9.3                                ...           6 years ago
  • 4.0.0-nightly.2020.9.1                                ...           6 years ago
  • 4.0.0-nightly.2020.8.29                                ...           6 years ago
  • 4.0.0-nightly.2020.8.25                                ...           6 years ago
  • 4.0.0-nightly.2020.8.24                                ...           6 years ago
  • 4.0.0-nightly.2020.8.17                                ...           6 years ago
  • 4.0.0-nightly.2020.8.10                                ...           6 years ago
  • 4.0.0-nightly.2020.8.4                                ...           6 years ago
  • 4.0.0-nightly.2020.8.1                                ...           6 years ago
  • 4.0.0-nightly.2020.7.31                                ...           6 years ago
  • 4.0.0-nightly.2020.7.25                                ...           6 years ago
  • 4.0.0-nightly.2020.7.24                                ...           6 years ago
  • 4.0.2                                ...           8 years ago
  • 4.0.1                                ...           8 years ago
  • 4.0.0                                ...           8 years ago
  • 4.0.0-rc.2                                ...           9 years ago
  • 4.0.0-rc.0                                ...           9 years ago
  • 2.1.0                                ...           10 years ago
  • 2.0.2                                ...           10 years ago
  • 2.0.1                                ...           11 years ago
  • 2.0.0                                ...           11 years ago
  • 1.2.1                                ...           11 years ago
  • 1.2.0                                ...           11 years ago
  • 1.1.6                                ...           11 years ago
  • 1.1.5                                ...           11 years ago
  • 1.1.4                                ...           11 years ago
  • 1.1.3                                ...           12 years ago
  • 1.1.2                                ...           12 years ago
  • 1.1.1                                ...           12 years ago
  • 1.1.0                                ...           12 years ago
  • 1.0.0                                ...           12 years ago
Downloads
Total 132
Today 0
This Week 8
This Month 127
Last Day 0
Last Week 57
Last Month 0
Dependencies (1)
Dev Dependencies (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE