Socket
Socket
Sign inDemoInstall

postcss-discard-empty

Package Overview
Dependencies
5
Maintainers
1
Versions
42
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
Maintainers
1
Install size
0.978 MB
Created

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 Build Status NPM version Dependency Status

Discard empty rules and values with PostCSS.

Install via npm:

npm install postcss-discard-empty --save

Example

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

var css = '@font-face; h1 {} {color:blue} h2 {color:} h3 {color:red}';
console.log(postcss(empty()).process(css).css);

// => 'h3 {color:red}'

For more examples see the tests.

Contributing

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

License

MIT © Ben Briggs

Keywords

FAQs

Last updated on 02 Apr 2015

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