Socket
Socket
Sign inDemoInstall

postcss-discard

Package Overview
Dependencies
8
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    postcss-discard

PostCSS plugin to discard rules, atrules or declarations by selector, RegExp or callback function


Version published
Maintainers
1
Install size
2.24 MB
Created

Readme

Source

PostCSS Discard Build Status

PostCSS plugin to discard rules by selector, RegExp, or @type. Also usable to generate a diff from two stylesheets

Usage

const discard = require('postcss-discard');
postcss([discard(options)]);

See PostCSS docs for examples for your environment.

Options
NameTypeDescription
atruleString, RegExp, FunctionMatch atrule like @font-face
ruleString, RegExp, FunctionMatch rule like .big-background-image {...}
declString, RegExp, FunctionMatch declarations
cssStringCSS String or path to file containing css

You can also pass a filter function for any of the supported types. The function is invoked with two arguments (node, value).

  • node The currently processed AST node generated by postcss.
  • value Current value.

Return true if the element should be discarded.

Examples

Diffing stylesheets

postcss(discard({css: 'STYLES TO BE REMOVED'})).process('ORIGINAL CSS').css;

Discard by specifying rules

.bg {
  width: 100%;
  height: 100%;
  background-image: url('some/big/image.png');
}

@font-face {
  font-family: 'My awesome font';
}

@media print {
  ...;
}
postcss([
  discard({
    atrule: ['@font-face', /print/],
  }),
]);
.bg {
  width: 100%;
  height: 100%;
}

Keywords

FAQs

Last updated on 29 May 2021

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