Skip to content

Commit 95442cd

Browse files
committed
defer normaizalition to postcss
1 parent 6f02fef commit 95442cd

26 files changed

Lines changed: 8 additions & 80 deletions

‎lib/apply-raws.js‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@ module.exports = function applyRaws(bundle) {
44
bundle.forEach((stmt, index) => {
55
if (index === 0) return
66

7-
if (stmt.parent) {
8-
const { before } = stmt.parent.node.raws
9-
if (stmt.type === "nodes") stmt.nodes[0].raws.before = before
10-
else stmt.node.raws.before = before
11-
} else if (stmt.type === "nodes") {
12-
stmt.nodes[0].raws.before = stmt.nodes[0].raws.before || "\n"
13-
}
7+
if (stmt.type === "nodes") delete stmt.nodes[0].raws.before
8+
else if (stmt.parent) delete stmt.node.raws.before
149
})
1510
}

‎test/fixtures/cyclical-skip-duplicates.expected.css‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,17 @@
33
.b {
44
color: red;
55
}
6-
76
.a {
87
color: blue;
98
}
10-
119
@media screen {
12-
1310
@media all {
14-
1511
.a {
1612
color: aquamarine;
1713
}
1814
}
1915
}
20-
2116
@media screen {
22-
2317
.a {
2418
color: pink;
2519
}

‎test/fixtures/cyclical.expected.css‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,23 @@
33
.b {
44
color: red;
55
}
6-
76
.a {
87
color: blue;
98
}
109
.a {
1110
color: blue;
1211
}
13-
1412
.b {
1513
color: red;
1614
}
17-
1815
@media screen {
19-
2016
@media all {
21-
2217
.a {
2318
color: aquamarine;
2419
}
2520
}
2621
}
27-
2822
@media screen {
29-
3023
.a {
3124
color: pink;
3225
}
Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,11 @@
11
p { color: green; }
2-
32
p { color: blue; }
4-
53
@media (min-width: 320px) {
6-
74
@layer foo {
85
p { color: green; } } }
9-
106
@media (min-width: 320px) {
11-
127
@layer foo {
13-
14-
p { color: blue; } } }
15-
16-
/* Mixed imports: */
17-
p { color: pink; }
18-
19-
/* url encoded: */
8+
p { color: blue; } } } /* Mixed imports: */
9+
p { color: pink; } /* url encoded: */
2010
bar { color: green }
2111
bar { color: pink }

‎test/fixtures/duplicates.expected.css‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ foo{}
77
@media screen{
88
foo{}
99
}
10-
1110
proxy {}
1211
import {}
13-
1412
content{}

‎test/fixtures/filter-all.expected.css‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@
88
@import url("foobar.css") screen and (min-width: 25em);
99
@import url('foobarbaz.css');
1010
@import url('foobarbaz.css') print, screen and (min-width: 25em);
11-
1211
content{}

‎test/fixtures/filter-some.expected.css‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
@import url("foobar.css");
3-
@import url("foobar.css") screen and (min-width: 25em);foo{}@media screen{
3+
@import url("foobar.css") screen and (min-width: 25em);
4+
foo{}
5+
@media screen{
46
foo{}
57
}
68
bar{}
@@ -15,5 +17,4 @@ foobarbaz{}
1517
@media print, screen and (min-width: 25em){
1618
foobarbaz{}
1719
}
18-
1920
content{}

‎test/fixtures/ignore.expected.css‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,4 @@
2020
@media (min-width: 25em){
2121
ignore{}
2222
}
23-
2423
content{}
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
.sugarbar{
22
color: blue
33
}
4-
54
import.sugarbar{}
6-
75
.sugar{
86
color: white
97
}
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
bar{}
2-
32
foo.recursive{
43
color: red
54
}

0 commit comments

Comments
 (0)