@amatiasq/postcss-discard-duplicates

2.1.1 • Public • Published

postcss-discard-duplicates Build Status NPM version Dependency Status

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
}

Options

retainFirstOccurrence

Type: Boolean
Default: false

When true, only the first occurrence of any duplicates found will be retained.

When false, the last occurrence of any duplicates found will be retained (this is the default behavior).

Example

When retainFirstOccurrence = true.

Input

h1 {
    margin: 0 auto;
}
h2 {
    color: #333;
}
h1 {
    margin: 0 auto;
}

Output

h1 {
    margin: 0 auto;
}
h2 {
    color: #333;
}

Usage

See the PostCSS documentation for examples for your environment.

Contributors

Thanks goes to these wonderful people (emoji key):


Ben Briggs

💻 📖 👀 ⚠️

Bogdan Chadkin

💻 👀 ⚠️

Lee Houghton

💻

Andy Jansson

💻 ⚠️

This project follows the all-contributors specification. Contributions of any kind welcome!

License

MIT © Ben Briggs

Package Sidebar

Install

npm i @amatiasq/postcss-discard-duplicates

Weekly Downloads

1

Version

2.1.1

License

MIT

Unpacked Size

11.2 kB

Total Files

5

Last publish

Collaborators

  • amatiasq