@@ -28,50 +28,56 @@ function makeRequestableIcssImports(icssImports) {
28
28
} , { } ) ;
29
29
}
30
30
31
- export default postcss . plugin ( 'postcss-icss-parser' , ( ) => ( css , result ) => {
32
- const importReplacements = Object . create ( null ) ;
33
- const extractedICSS = extractICSS ( css ) ;
34
- const icssImports = makeRequestableIcssImports ( extractedICSS . icssImports ) ;
35
-
36
- for ( const [ importIndex , url ] of Object . keys ( icssImports ) . entries ( ) ) {
37
- const importName = `___CSS_LOADER_ICSS_IMPORT_${ importIndex } ___` ;
38
-
39
- result . messages . push (
40
- {
41
- type : 'import' ,
42
- value : { type : 'icss' , importName, url } ,
43
- } ,
44
- {
45
- type : 'api-import' ,
46
- value : { type : 'internal' , importName, dedupe : true } ,
31
+ export default postcss . plugin (
32
+ 'postcss-icss-parser' ,
33
+ ( options ) => ( css , result ) => {
34
+ const importReplacements = Object . create ( null ) ;
35
+ const extractedICSS = extractICSS ( css ) ;
36
+ const icssImports = makeRequestableIcssImports ( extractedICSS . icssImports ) ;
37
+
38
+ for ( const [ importIndex , url ] of Object . keys ( icssImports ) . entries ( ) ) {
39
+ const importName = `___CSS_LOADER_ICSS_IMPORT_${ importIndex } ___` ;
40
+
41
+ result . messages . push (
42
+ {
43
+ type : 'import' ,
44
+ value : {
45
+ importName,
46
+ url : options . urlHandler ? options . urlHandler ( url ) : url ,
47
+ } ,
48
+ } ,
49
+ {
50
+ type : 'api-import' ,
51
+ value : { type : 'internal' , importName, dedupe : true } ,
52
+ }
53
+ ) ;
54
+
55
+ const tokenMap = icssImports [ url ] ;
56
+ const tokens = Object . keys ( tokenMap ) ;
57
+
58
+ for ( const [ replacementIndex , token ] of tokens . entries ( ) ) {
59
+ const replacementName = `___CSS_LOADER_ICSS_IMPORT_${ importIndex } _REPLACEMENT_${ replacementIndex } ___` ;
60
+ const localName = tokenMap [ token ] ;
61
+
62
+ importReplacements [ token ] = replacementName ;
63
+
64
+ result . messages . push ( {
65
+ type : 'icss-replacement' ,
66
+ value : { replacementName, importName, localName } ,
67
+ } ) ;
47
68
}
48
- ) ;
49
-
50
- const tokenMap = icssImports [ url ] ;
51
- const tokens = Object . keys ( tokenMap ) ;
52
-
53
- for ( const [ replacementIndex , token ] of tokens . entries ( ) ) {
54
- const replacementName = `___CSS_LOADER_ICSS_IMPORT_${ importIndex } _REPLACEMENT_${ replacementIndex } ___` ;
55
- const localName = tokenMap [ token ] ;
56
-
57
- importReplacements [ token ] = replacementName ;
58
-
59
- result . messages . push ( {
60
- type : 'icss-replacement' ,
61
- value : { replacementName, importName, localName } ,
62
- } ) ;
63
69
}
64
- }
65
70
66
- if ( Object . keys ( importReplacements ) . length > 0 ) {
67
- replaceSymbols ( css , importReplacements ) ;
68
- }
71
+ if ( Object . keys ( importReplacements ) . length > 0 ) {
72
+ replaceSymbols ( css , importReplacements ) ;
73
+ }
69
74
70
- const { icssExports } = extractedICSS ;
75
+ const { icssExports } = extractedICSS ;
71
76
72
- for ( const name of Object . keys ( icssExports ) ) {
73
- const value = replaceValueSymbols ( icssExports [ name ] , importReplacements ) ;
77
+ for ( const name of Object . keys ( icssExports ) ) {
78
+ const value = replaceValueSymbols ( icssExports [ name ] , importReplacements ) ;
74
79
75
- result . messages . push ( { type : 'export' , value : { name, value } } ) ;
80
+ result . messages . push ( { type : 'export' , value : { name, value } } ) ;
81
+ }
76
82
}
77
- } ) ;
83
+ ) ;
0 commit comments