Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

postcss-discard-duplicates

Package Overview
Dependencies
Maintainers
8
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-discard-duplicates

Discard duplicate rules in your CSS files with PostCSS.

  • 5.0.0-rc.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9.3M
decreased by-19.56%
Maintainers
8
Weekly downloads
 
Created

What is postcss-discard-duplicates?

The postcss-discard-duplicates package is a PostCSS plugin designed to remove duplicate rules, declarations, and @rules from your CSS. This helps in reducing the file size and cleaning up the CSS for better performance and readability.

What are postcss-discard-duplicates's main functionalities?

Discard duplicate rules

This feature removes duplicate CSS rules. If two or more rules are identical, only one is kept.

"const postcss = require('postcss');
const discardDuplicates = require('postcss-discard-duplicates');

postcss([ discardDuplicates() ])
.process('a { color: black; } a { color: black; }', { from: undefined })
.then(result => {
  console.log(result.css);
  // Output: 'a { color: black; }'
});"

Discard duplicate declarations within a rule

This feature removes duplicate declarations within a single rule, keeping only one instance of the declaration.

"const postcss = require('postcss');
const discardDuplicates = require('postcss-discard-duplicates');

postcss([ discardDuplicates() ])
.process('a { color: black; color: black; }', { from: undefined })
.then(result => {
  console.log(result.css);
  // Output: 'a { color: black; }'
});"

Discard duplicate @rules

This feature removes duplicate @rules from the CSS, ensuring that only one instance of each @rule is present.

"const postcss = require('postcss');
const discardDuplicates = require('postcss-discard-duplicates');

postcss([ discardDuplicates() ])
.process('@font-face { font-family: 'MyFont'; src: url('myfont.woff2'); }
@font-face { font-family: 'MyFont'; src: url('myfont.woff2'); }', { from: undefined })
.then(result => {
  console.log(result.css);
  // Output: '@font-face { font-family: 'MyFont'; src: url('myfont.woff2'); }'
});"

Other packages similar to postcss-discard-duplicates

Keywords

FAQs

Package last updated on 19 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc