index.js
797 Bytes
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
31
32
33
34
35
36
37
38
39
40
41
42
'use strict';
exports.__esModule = true;
var _postcss = require('postcss');
function dedupe(root) {
root.each(function (node) {
if (node.nodes) {
dedupe(node);
}
});
if (root.nodes.length < 2) {
return;
}
var toRemove = [];
var map = {};
root.each(function (node) {
if (node.type === "comment") {
return;
}
var str = node.toString();
var existing = map[str];
if (existing) {
toRemove.push(existing);
}
map[str] = node;
});
while (toRemove.length > 0) {
toRemove.pop().remove();
}
}
exports.default = (0, _postcss.plugin)('postcss-discard-duplicates', function () {
return dedupe;
});
module.exports = exports['default'];