@@ -22,15 +22,18 @@ var parserPlugin = postcss.plugin("css-loader-parser", function(options) {
22
22
var urlItems = [ ] ;
23
23
24
24
function replaceImportsInString ( str ) {
25
- var tokens = str . split ( / ( \S + ) / ) ;
26
- tokens = tokens . map ( function ( token ) {
27
- var importIndex = imports [ "$" + token ] ;
28
- if ( typeof importIndex === "number" ) {
29
- return "___CSS_LOADER_IMPORT___" + importIndex + "___" ;
30
- }
31
- return token ;
32
- } ) ;
33
- return tokens . join ( "" ) ;
25
+ if ( options . import ) {
26
+ var tokens = str . split ( / ( \S + ) / ) ;
27
+ tokens = tokens . map ( function ( token ) {
28
+ var importIndex = imports [ "$" + token ] ;
29
+ if ( typeof importIndex === "number" ) {
30
+ return "___CSS_LOADER_IMPORT___" + importIndex + "___" ;
31
+ }
32
+ return token ;
33
+ } ) ;
34
+ return tokens . join ( "" ) ;
35
+ }
36
+ return str ;
34
37
}
35
38
36
39
css . walkAtRules ( "import" , function ( rule ) {
@@ -83,23 +86,27 @@ var parserPlugin = postcss.plugin("css-loader-parser", function(options) {
83
86
value . nodes . forEach ( function ( item ) {
84
87
switch ( item . type ) {
85
88
case "item" :
86
- var importIndex = imports [ "$" + item . name ] ;
87
- if ( typeof importIndex === "number" ) {
88
- item . name = "___CSS_LOADER_IMPORT___" + importIndex + "___" ;
89
+ if ( options . import ) {
90
+ var importIndex = imports [ "$" + item . name ] ;
91
+ if ( typeof importIndex === "number" ) {
92
+ item . name = "___CSS_LOADER_IMPORT___" + importIndex + "___" ;
93
+ }
89
94
}
90
95
break ;
91
96
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
- } ) ;
97
+ if ( options . url ) {
98
+ if ( ! / ^ # / . test ( item . url ) && loaderUtils . isUrlRequest ( item . url , options . root ) ) {
99
+ item . stringType = "" ;
100
+ delete item . innerSpacingBefore ;
101
+ delete item . innerSpacingAfter ;
102
+ var url = item . url ;
103
+ item . url = "___CSS_LOADER_URL___" + urlItems . length + "___" ;
104
+ urlItems . push ( {
105
+ url : url
106
+ } ) ;
107
+ }
108
+ break ;
101
109
}
102
- break ;
103
110
}
104
111
} ) ;
105
112
} ) ;
@@ -129,7 +136,9 @@ module.exports = function processCss(inputSource, inputMap, options, callback) {
129
136
130
137
var parserOptions = {
131
138
root : root ,
132
- mode : options . mode
139
+ mode : options . mode ,
140
+ url : ! query . hasOwnProperty ( 'url' ) ,
141
+ import : ! query . hasOwnProperty ( 'import' )
133
142
} ;
134
143
135
144
var pipeline = postcss ( [
0 commit comments