@@ -8,6 +8,8 @@ var loaderUtils = require("loader-utils");
8
8
module . exports = function ( content ) {
9
9
this . cacheable && this . cacheable ( ) ;
10
10
var result = [ ] ;
11
+ var query = loaderUtils . parseQuery ( this . query ) ;
12
+ var root = query . root ;
11
13
var tree = csso . parse ( content , "stylesheet" ) ;
12
14
if ( tree && this && this . minimize ) {
13
15
tree = csso . compress ( tree ) ;
@@ -37,19 +39,19 @@ module.exports = function(content) {
37
39
var uriRegExp = / % C S S U R L \[ % ( .* ?) % \] C S S U R L % / g;
38
40
css = css . replace ( uriRegExp , function ( str ) {
39
41
var match = / ^ % C S S U R L \[ % ( .* ?) % \] C S S U R L % $ / . exec ( str ) ;
40
- if ( / ^ d a t a : | ^ ( h t t p s ? : ) ? \/ \/ / . test ( match [ 1 ] ) ) return match [ 1 ] ;
42
+ if ( ! loaderUtils . isUrlRequest ( match [ 1 ] , root ) ) return match [ 1 ] ;
41
43
var idx = match [ 1 ] . indexOf ( "?" ) ;
42
44
if ( idx < 0 ) idx = match [ 1 ] . indexOf ( "#" ) ;
43
45
if ( idx > 0 ) {
44
46
// in cases like url('webfont.eot?#iefix')
45
47
var url = JSON . parse ( "\"" + match [ 1 ] . substr ( 0 , idx ) + "\"" ) ;
46
- return "\"+require(" + JSON . stringify ( urlToRequire ( url ) ) + ")+\"" + match [ 1 ] . substr ( idx ) ;
48
+ return "\"+require(" + JSON . stringify ( loaderUtils . urlToRequest ( url , root ) ) + ")+\"" + match [ 1 ] . substr ( idx ) ;
47
49
} else if ( idx === 0 ) {
48
50
// only hash
49
51
return match [ 1 ] ;
50
52
}
51
53
var url = JSON . parse ( "\"" + match [ 1 ] + "\"" ) ;
52
- return "\"+require(" + JSON . stringify ( urlToRequire ( url ) ) + ")+\"" ;
54
+ return "\"+require(" + JSON . stringify ( loaderUtils . urlToRequest ( url , root ) ) + ")+\"" ;
53
55
} ) ;
54
56
result . push ( css ) ;
55
57
var cssRequest = loaderUtils . getRemainingRequest ( this ) ;
@@ -63,12 +65,6 @@ module.exports = function(content) {
63
65
this . callback ( null , stringWithMap . code , stringWithMap . map . toJSON ( ) ) ;
64
66
}
65
67
66
- function urlToRequire ( url ) {
67
- if ( / ^ ~ / . test ( url ) )
68
- return url . substring ( 1 ) ;
69
- else
70
- return "./" + url ;
71
- }
72
68
function extractImports ( tree ) {
73
69
var results = [ ] ;
74
70
var removes = [ ] ;
0 commit comments