|
|
|
@ -196,12 +196,13 @@ const visitors = {
|
|
|
|
|
SelectorList(node, { state, next, path }) {
|
|
|
|
|
// Only add comments if we're not inside a complex selector that itself is unused
|
|
|
|
|
if (!path.find((n) => n.type === 'ComplexSelector' && !n.metadata.used)) {
|
|
|
|
|
const children = node.children;
|
|
|
|
|
let pruning = false;
|
|
|
|
|
let prune_start = node.children[0].start;
|
|
|
|
|
let prune_start = children[0].start;
|
|
|
|
|
let last = prune_start;
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < node.children.length; i += 1) {
|
|
|
|
|
const selector = node.children[i];
|
|
|
|
|
for (let i = 0; i < children.length; i += 1) {
|
|
|
|
|
const selector = children[i];
|
|
|
|
|
|
|
|
|
|
if (selector.metadata.used === pruning) {
|
|
|
|
|
if (pruning) {
|
|
|
|
@ -221,10 +222,17 @@ const visitors = {
|
|
|
|
|
state.code.prependRight(selector.start, '/* (unused) ');
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// If this is not the last selector add a separator
|
|
|
|
|
const separator = i !== children.length - 1 ? ',' : '';
|
|
|
|
|
|
|
|
|
|
if (state.minify) {
|
|
|
|
|
prune_start = last;
|
|
|
|
|
if (separator) {
|
|
|
|
|
while (state.code.original[prune_start - 1] !== ',') prune_start++;
|
|
|
|
|
state.code.update(last, prune_start, separator);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
state.code.overwrite(last, selector.start, ' /* (unused) ');
|
|
|
|
|
state.code.overwrite(last, selector.start, `${separator} /* (unused) `);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|