postcss-filter-declarations
v2.0.0
Published
PostCSS plugin to filter declarations by property names
Downloads
9
Maintainers
Readme
postcss-filter-declarations
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
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.