Skip to content

Commit 1bfeb1e

Browse files
committed
added comment with source filename
1 parent aef7131 commit 1bfeb1e

File tree

11 files changed

+28
-2
lines changed

11 files changed

+28
-2
lines changed

lib/resolveDeps.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

3-
const {dirname} = require('path');
3+
const {comment} = require('postcss');
4+
const {dirname, relative} = require('path');
45
const {readFileSync} = require('fs');
56
const {resolveModule} = require('./resolveModule');
67
const {resolvePaths} = require('./resolvePaths');
@@ -90,7 +91,10 @@ function resolveDeps(ast, result) {
9091
// resolve paths
9192
if (cwd !== rootDir) resolvePaths(ast, cwd, rootDir);
9293

93-
// append comment
94+
rootTree.append(comment({
95+
text: ` imported from ${relative(rootDir, selfPath)} `,
96+
}));
97+
9498
rootTree.append(ast.nodes);
9599
}
96100

test/case/opts-alias/expected.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
/* imported from lib/button/button.css */
12
._button_button {
23
/*common button styles*/
34
}
5+
/* imported from source.css */
46
._source_continueButton {
57
color: green
68
}

test/case/opts-explicit-exports/expected.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
continueButton: _source_continueButton;
33
userInput: _source_userInput
44
}
5+
/* imported from source.css */
56
._source_continueButton {
67
color: green
78
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
/* imported from lib/button.css */
12
._button_button {
23
/*common button styles*/
34
}
5+
/* imported from source.css */
46
._source_continueButton {
57
color: green
68
}

test/case/opts-modules/expected.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
/* imported from lib/button/index.css */
12
._index_button {
23
/*common button styles*/
34
}
5+
/* imported from source.css */
46
._source_continueButton {
57
color: green
68
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1+
/* imported from b.css */
12
._b_aa {
23
/**/
34
}
45
._b_bb {
56
/**/
67
}
8+
/* imported from c.css */
79
._c_aa {
810
/**/
911
}
1012
._c_bb {}
13+
/* imported from a.css */
1114
._a_aa {}
1215
._a_bb {}
16+
/* imported from source.css */
1317
._source_resultA {}
1418
._source_resultB {}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
/* imported from lib/color.css */
12
._color_green {
23
color: green
34
}
5+
/* imported from lib/button/button.css */
46
._button_button {
57
/*common button styles*/
68
}
9+
/* imported from source.css */
710
._source_continueButton {}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
/* imported from node_modules/button/button.css */
12
._button_button {
23
/*common button styles*/
34
}
5+
/* imported from source.css */
46
._source_continueButton {
57
color: green
68
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
/* imported from button/my-awesome-button.css */
12
._my-awesome-button_button {
23
/*common button styles*/
34
}
5+
/* imported from source.css */
46
._source_continueButton {
57
color: green
68
}

test/case/resolve-paths/expected.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* imported from lib/nested.css */
12
/* should be './lib/reset1.css' */
23
@import url('./lib/reset1.css');
34
/* should be './lib/reset2.css' */
@@ -6,4 +7,5 @@
67
/* should be ./lib/spin-icon.svg */
78
background: url(./lib/spin-icon.svg) 0 0 no-repeat
89
}
10+
/* imported from source.css */
911
._source_relative {}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
:export {
22
continueButton: _source_continueButton _button_button
33
}
4+
/* imported from node_modules/library/button.css */
45
._button_button {
56
/*common button styles*/
67
}
8+
/* imported from source.css */
79
._source_continueButton {
810
color: green
911
}

0 commit comments

Comments
 (0)