Compare adjacent rules ignoring whitespace
This commit is contained in:
parent
8845d112fb
commit
15642fbcc8
3 changed files with 19 additions and 1 deletions
|
|
@ -22,7 +22,13 @@ export default function collapseAdjacentRules() {
|
|||
|
||||
if (node.type === 'atrule' && node.name === 'font-face') {
|
||||
currentRule = node
|
||||
} else if (properties.every((property) => node[property] === currentRule[property])) {
|
||||
} else if (
|
||||
properties.every(
|
||||
(property) =>
|
||||
(node[property] ?? '').replace(/\s+/g, ' ') ===
|
||||
(currentRule[property] ?? '').replace(/\s+/g, ' ')
|
||||
)
|
||||
) {
|
||||
currentRule.append(node.nodes)
|
||||
node.remove()
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -36,6 +36,11 @@
|
|||
.font-bold {
|
||||
font-weight: 700;
|
||||
}
|
||||
.foo,
|
||||
.bar {
|
||||
color: black;
|
||||
font-weight: 700;
|
||||
}
|
||||
@media (min-width: 640px) {
|
||||
.sm\:text-center {
|
||||
text-align: center;
|
||||
|
|
|
|||
|
|
@ -47,6 +47,13 @@ test('collapse adjacent rules', () => {
|
|||
url("/fonts/ProximaNova.woff") format("woff");
|
||||
}
|
||||
}
|
||||
.foo, .bar {
|
||||
color: black;
|
||||
}
|
||||
.foo,
|
||||
.bar {
|
||||
font-weight: 700;
|
||||
}
|
||||
`
|
||||
|
||||
return run(css, config).then((result) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue