JSPM

postcss-filter-declarations

2.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q20274F

PostCSS plugin to filter declarations by property names

Package Exports

  • postcss-filter-declarations

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (postcss-filter-declarations) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

postcss-filter-declarations

NPM version Build Status Build status Coverage Status devDependency Status

PostCSS plugin to filter declarations by property names

var fs = require('fs');

var postcss = require('postcss');
var filterDeclarations = require('postcss-filter-declarations');

postcss()
  .use(filterDeclarations({props: ['display', 'color']}))
  .process(fs.readFileSync('path/to/css/file'))
  .css;
.menubar {
  display: block;
  position: fixed;
  color: gray;
}

@media print {
  h1 {
    font-size: 16px;
  }

  a {
    color: blue;
  }
}

.menubar {
  display: block;
  color: gray;
}
@media print {
  h1 {
  }

  a {
    color: blue;
  }
}

Installation

Use npm.

npm install postcss-filter-declarations

API

var filterDeclarations = require('postcss-filter-declarations');

filterDeclarations([options])

options: Object
Return: Function

options.properties

(alias: options.props)

Type: Stirng or Array of String
Default: []

Removes all CSS declarations except for the proerties specified by this option.

postcss()
  .use(filterDeclarations({
    pops: 'color'
  }))
  .process('a {color: red;} b {background: blue;}')
  .css; //=> 'a {color: red;} b {}'

options.exclude

Type: Boolean
Defult: false

true inverts the filtering result.

postcss()
  .use(filterDeclarations({
    pops: 'color',
    exclude: true
  }))
  .process('a {color: red;} b {background: blue;}')
  .css; //=> 'a {} b {background: blue;}'

License

Copyright (c) 2014 - 2015 Shinnosuke Watanabe

Licensed under the MIT License.