This repository was archived by the owner on Feb 6, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -19,12 +19,16 @@ module.exports = function(content) {
19
19
annotateUrls ( tree ) ;
20
20
21
21
imports . forEach ( function ( imp ) {
22
- if ( imp . media . length > 0 ) {
23
- result . push ( JSON . stringify ( "@media " + imp . media . join ( "" ) + "{" ) ) ;
24
- }
25
- result . push ( "require(" + JSON . stringify ( "!" + __filename + "!" + urlToRequire ( imp . url ) ) + ")" ) ;
26
- if ( imp . media . length > 0 ) {
27
- result . push ( JSON . stringify ( "}" ) ) ;
22
+ if ( / ^ d a t a : | ^ ( h t t p s ? : ) ? \/ \/ / . test ( imp . url ) ) {
23
+ result . push ( JSON . stringify ( "@import url(" + imp . url + ")" + imp . media . join ( "" ) + ";" ) ) ;
24
+ } else {
25
+ if ( imp . media . length > 0 ) {
26
+ result . push ( JSON . stringify ( "@media " + imp . media . join ( "" ) + "{" ) ) ;
27
+ }
28
+ result . push ( "require(" + JSON . stringify ( "!" + __filename + "!" + urlToRequire ( imp . url ) ) + ")" ) ;
29
+ if ( imp . media . length > 0 ) {
30
+ result . push ( JSON . stringify ( "}" ) ) ;
31
+ }
28
32
}
29
33
} ) ;
30
34
}
Original file line number Diff line number Diff line change @@ -50,6 +50,10 @@ describe("url", function() {
50
50
"require(" + JSON . stringify ( "!" + path . join ( __dirname , ".." , "index.js" ) + "!test/css" ) + ")" ,
51
51
"\"}\"" ,
52
52
"\"\\n.class { a: b c d; }\"" ] ) ;
53
+ test ( "import external" , "@import url(http://example.com/style.css);\n@import url(\"//example.com/style.css\");" ,
54
+ [ "\"@import url(http://example.com/style.css);\"" ,
55
+ "\"@import url(//example.com/style.css);\"" ,
56
+ "\"\\n\"" ] ) ;
53
57
test ( "background img" , ".class { background: green url( \"img.png\" ) xyz }" ,
54
58
[ "\".class { background: green url( \"+require(\"./img.png\")+\" ) xyz }\"" ] ) ;
55
59
test ( "background img 2" , ".class { background: green url(~img/png ) url(aaa) xyz }" ,
You can’t perform that action at this time.
0 commit comments