@@ -77,30 +77,55 @@ var parserPlugin = postcss.plugin("css-loader-parser", function(options) {
77
77
exports [ exportName ] = replaceImportsInString ( exports [ exportName ] ) ;
78
78
} ) ;
79
79
80
+ function processNode ( item , isValue ) {
81
+ switch ( item . type ) {
82
+ case "value" :
83
+ item . nodes . forEach ( function ( node ) {
84
+ processNode ( node , true ) ;
85
+ } ) ;
86
+ break ;
87
+ case "nested-item" :
88
+ item . nodes . forEach ( function ( node ) {
89
+ processNode ( node ) ;
90
+ } ) ;
91
+ break ;
92
+ case "item" :
93
+ var importIndex = imports [ "$" + item . name ] ;
94
+ if ( typeof importIndex === "number" ) {
95
+ item . name = "___CSS_LOADER_IMPORT___" + importIndex + "___" ;
96
+ }
97
+ break ;
98
+ case "url" :
99
+ if ( ! / ^ # / . test ( item . url ) && loaderUtils . isUrlRequest ( item . url , options . root ) ) {
100
+ item . stringType = "" ;
101
+ delete item . innerSpacingBefore ;
102
+ delete item . innerSpacingAfter ;
103
+ var url ;
104
+
105
+ if ( isValue ) {
106
+ if ( loaderUtils . isUrlRequest ( url , options . root ) && options . mode === "global" ) {
107
+ url = loaderUtils . urlToRequest ( item . url , options . root ) ;
108
+ } else {
109
+ url = item . url ;
110
+ }
111
+ } else {
112
+ url = item . url ;
113
+ }
114
+
115
+ item . url = "___CSS_LOADER_URL___" + urlItems . length + "___" ;
116
+ urlItems . push ( {
117
+ url : url
118
+ } ) ;
119
+ }
120
+ break ;
121
+ }
122
+ }
123
+
80
124
css . walkDecls ( function ( decl ) {
81
125
var values = Tokenizer . parseValues ( decl . value ) ;
82
126
values . nodes . forEach ( function ( value ) {
83
- value . nodes . forEach ( function ( item ) {
84
- switch ( item . type ) {
85
- case "item" :
86
- var importIndex = imports [ "$" + item . name ] ;
87
- if ( typeof importIndex === "number" ) {
88
- item . name = "___CSS_LOADER_IMPORT___" + importIndex + "___" ;
89
- }
90
- break ;
91
- case "url" :
92
- if ( ! / ^ # / . test ( item . url ) && loaderUtils . isUrlRequest ( item . url , options . root ) ) {
93
- item . stringType = "" ;
94
- delete item . innerSpacingBefore ;
95
- delete item . innerSpacingAfter ;
96
- var url = item . url ;
97
- item . url = "___CSS_LOADER_URL___" + urlItems . length + "___" ;
98
- urlItems . push ( {
99
- url : url
100
- } ) ;
101
- }
102
- break ;
103
- }
127
+ value . nodes . forEach ( function ( node ) {
128
+ processNode ( node ) ;
104
129
} ) ;
105
130
} ) ;
106
131
decl . value = Tokenizer . stringifyValues ( values ) ;
0 commit comments