@@ -9,25 +9,27 @@ module.exports = function(content) {
9
9
this . cacheable && this . cacheable ( ) ;
10
10
var result = [ ] ;
11
11
var tree = csso . parse ( content , "stylesheet" ) ;
12
- if ( this && this . minimize ) {
12
+ if ( tree && this && this . minimize ) {
13
13
tree = csso . compress ( tree ) ;
14
14
tree = csso . cleanInfo ( tree ) ;
15
15
}
16
16
17
- var imports = extractImports ( tree ) ;
18
- annotateUrls ( tree ) ;
17
+ if ( tree ) {
18
+ var imports = extractImports ( tree ) ;
19
+ annotateUrls ( tree ) ;
19
20
20
- imports . forEach ( function ( imp ) {
21
- if ( imp . media . length > 0 ) {
22
- result . push ( JSON . stringify ( "@media " + imp . media . join ( "" ) + "{" ) ) ;
23
- }
24
- result . push ( "require(" + JSON . stringify ( "!" + __filename + "!" + urlToRequire ( imp . url ) ) + ")" ) ;
25
- if ( imp . media . length > 0 ) {
26
- result . push ( JSON . stringify ( "}" ) ) ;
27
- }
28
- } ) ;
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 ( "}" ) ) ;
28
+ }
29
+ } ) ;
30
+ }
29
31
30
- var css = JSON . stringify ( csso . translate ( tree ) ) ;
32
+ var css = JSON . stringify ( tree ? csso . translate ( tree ) : "" ) ;
31
33
var uriRegExp = / % C S S U R L \[ % ( .* ?) % \] C S S U R L % / g;
32
34
css = css . replace ( uriRegExp , function ( str ) {
33
35
var match = / ^ % C S S U R L \[ % ( .* ?) % \] C S S U R L % $ / . exec ( str ) ;
0 commit comments