Skip to content

Commit 12e7d42

Browse files
committed
better output order and newlines
1 parent b351acb commit 12e7d42

File tree

9 files changed

+62
-10
lines changed

9 files changed

+62
-10
lines changed

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ const processor = (css) => {
2626
});
2727

2828
// If we've found any imports, insert :import rules
29-
Object.keys(imports).forEach(path => {
29+
Object.keys(imports).reverse().forEach(path => {
3030
let pathImports = imports[path];
3131
css.prepend(postcss.rule({
3232
selector: `:import("${path}")`,
33-
before: "\n",
33+
after: "\n",
3434
nodes: Object.keys(pathImports).map(importedSymbol => postcss.decl({
3535
prop: importedSymbol,
3636
value: pathImports[importedSymbol],

test/test-cases/import-consolidate/expected.css

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
2-
:import("path/other-lib.css") {
3-
otherLibImport: __tmp_otherLibImport_rand3;
4-
}
51
:import("path/library.css") {
62
importName: __tmp_importName_rand0;
73
secondImport: __tmp_secondImport_rand1;
84
thirdImport: __tmp_thirdImport_rand2;
95
}
6+
:import("path/other-lib.css") {
7+
otherLibImport: __tmp_otherLibImport_rand3;
8+
}
109
:local(.exportName) {
1110
extends: __tmp_importName_rand0 __tmp_secondImport_rand1;
1211
other: rule;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
:import("path/library.css") {
2+
importName: __tmp_importName_rand0;
3+
importName2: __tmp_importName2_rand1;
4+
}
5+
6+
@media screen {
7+
:local(.exportName) {
8+
extends: __tmp_importName_rand0;
9+
extends: __tmp_importName2_rand1;
10+
other: rule2;
11+
}
12+
}
13+
14+
:local(.exportName) {
15+
extends: __tmp_importName_rand0;
16+
other: rule;
17+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@media screen {
2+
:local(.exportName) {
3+
extends: importName from "path/library.css";
4+
extends: importName2 from "path/library.css";
5+
other: rule2;
6+
}
7+
}
8+
9+
:local(.exportName) {
10+
extends: importName from "path/library.css";
11+
other: rule;
12+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
21
:import("path/library.css") {
32
importName: __tmp_importName_rand0;
4-
secondImport: __tmp_secondImport_rand1; }
3+
secondImport: __tmp_secondImport_rand1;
4+
}
55
:local(.exportName) { extends: __tmp_importName_rand0 __tmp_secondImport_rand1; other: rule; }
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
:import("path/library.css") {
2+
importName: __tmp_importName_rand0;
3+
secondImport: __tmp_secondImport_rand1;
4+
importName2: __tmp_importName2_rand3;
5+
}
6+
:import("path/library2.css") {
7+
importName: __tmp_importName_rand2;
8+
}
9+
:local(.exportName) {
10+
extends: __tmp_importName_rand0 __tmp_secondImport_rand1;
11+
extends: __tmp_importName_rand2;
12+
extends: __tmp_importName2_rand3;
13+
}
14+
:local(.exportName2) {
15+
extends: __tmp_secondImport_rand1;
16+
extends: __tmp_secondImport_rand1;
17+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
:local(.exportName) {
2+
extends: importName secondImport from 'path/library.css';
3+
extends: importName from 'path/library2.css';
4+
extends: importName2 from 'path/library.css';
5+
}
6+
:local(.exportName2) {
7+
extends: secondImport from 'path/library.css';
8+
extends: secondImport from 'path/library.css';
9+
}

test/test-cases/import-single-quotes/expected.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
:import("path/library.css") {
32
importName: __tmp_importName_rand0;
43
}

test/test-cases/import-within/expected.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
:import("path/library.css") {
32
importName: __tmp_importName_rand0;
43
}

0 commit comments

Comments
 (0)