2.0.0 • Published 3 years ago

postcss-discard v2.0.0

Weekly downloads
21,393
License
MIT
Repository
github
Last release
3 years ago

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%;
}
1.0.2

3 years ago

1.0.3

3 years ago

2.0.0

3 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.3.8

4 years ago

0.3.7

4 years ago

0.3.6

4 years ago

0.3.5

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.2

5 years ago

0.1.1

6 years ago

0.1.0

6 years ago