-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
30 lines (30 loc) · 1.03 KB
/
Copy pathindex.js
File metadata and controls
30 lines (30 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var postcss = require('postcss')
module.exports = postcss.plugin('postcss-remove-style', function(opts) {
opts = opts || {}
return function(css, result) {
for (let selector in opts) {
if (selector === '*') {
opts[selector].forEach(function(prop) {
css.walkDecls(prop, function(decl) {
decl.remove()
})
})
} else {
css.walkRules(function(rule) {
const styles = opts[rule.selector]
if (styles) {
if (styles === '*') {
rule.remove()
} else {
rule.walkDecls(function(decl) {
if (styles.indexOf(decl.prop) !== -1) {
decl.remove()
}
})
}
}
})
}
}
}
})