Socket
Socket
Sign inDemoInstall

postcss-discard-empty

Package Overview
Dependencies
4
Maintainers
8
Versions
41
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    postcss-discard-empty

Discard empty rules and values with PostCSS.


Version published
Weekly downloads
8.8M
decreased by-16.5%
Maintainers
8
Install size
5.07 kB
Created
Weekly downloads
 

Package description

What is postcss-discard-empty?

The postcss-discard-empty npm package is a PostCSS plugin that is used to remove empty rules, selectors, and at-rules from your CSS. This helps in reducing the size of the CSS file and cleaning up any unused or empty CSS declarations that may be left over after development or refactoring.

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

Discard empty rules

This feature removes CSS rules that have no declarations inside them. For example, 'a{}' would be removed from the CSS because it's an empty rule.

postcss([ require('postcss-discard-empty') ]).process('a{}').css

Discard empty at-rules

This feature removes at-rules that have no content. For example, '@media screen {}' would be removed because it contains no rules or declarations.

postcss([ require('postcss-discard-empty') ]).process('@media screen {}').css

Discard empty selectors

This feature removes selectors that have no declarations. In the given code, 'b{}' would be removed, leaving only the selector 'a' with its declaration.

postcss([ require('postcss-discard-empty') ]).process('a{ color: red; } b{}').css

Other packages similar to postcss-discard-empty

Readme

Source

postcss-discard-empty

Discard empty rules and values with PostCSS.

Install

With npm do:

npm install postcss-discard-empty --save

Example

For more examples see the tests.

Input

@font-face;
h1 {}
{color:blue}
h2 {color:}
h3 {color:red}

Output

h3 {color:red}

Usage

See the PostCSS documentation for examples for your environment.

Contributors

See CONTRIBUTORS.md.

License

MIT © Ben Briggs

Keywords

FAQs

Last updated on 10 Mar 2022

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc