mirror of
https://github.com/wu736139669/Monkey-Test.git
synced 2026-10-24 23:47:21 +00:00
21 lines
524 B
JavaScript
21 lines
524 B
JavaScript
'use strict';
|
|
var postcss = require('postcss');
|
|
|
|
function discardEmpty(node) {
|
|
if (node.nodes) { node.each(discardEmpty); }
|
|
|
|
if (
|
|
(node.type === 'decl' && !node.value) ||
|
|
(node.type === 'rule' && !node.selector || (node.nodes && !node.nodes.length)) ||
|
|
(node.type === 'atrule' && ((!node.nodes && !node.params) || (!node.params && !node.nodes.length)))
|
|
) {
|
|
node.removeSelf();
|
|
}
|
|
}
|
|
|
|
module.exports = postcss.plugin('postcss-discard-empty', function () {
|
|
return function (css) {
|
|
css.each(discardEmpty);
|
|
};
|
|
});
|