File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ var declWhitelist = ['extends'],
1818
1919var processor = function processor ( css , result ) {
2020 var imports = { } ;
21+
22+ // Find any declaration that supports imports
2123 css . eachDecl ( declFilter , function ( decl ) {
2224 var matches = decl . value . match ( matchImports ) ;
2325 if ( matches ) {
@@ -38,13 +40,18 @@ var processor = function processor(css, result) {
3840 } ) ( ) ;
3941 }
4042 } ) ;
43+
44+ // If we've found any imports, insert :import rules
4145 Object . keys ( imports ) . forEach ( function ( path ) {
4246 var pathImports = imports [ path ] ;
4347 console . log ( pathImports ) ;
4448 css . prepend ( _postcss2 [ 'default' ] . rule ( {
4549 selector : ':import("' + path + '")' ,
4650 nodes : Object . keys ( pathImports ) . map ( function ( importedSymbol ) {
47- return _postcss2 [ 'default' ] . decl ( { prop : importedSymbol , value : pathImports [ importedSymbol ] } ) ;
51+ return _postcss2 [ 'default' ] . decl ( {
52+ prop : importedSymbol ,
53+ value : pathImports [ importedSymbol ]
54+ } ) ;
4855 } )
4956 } ) ) ;
5057 } ) ;
Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ const declWhitelist = ['extends'],
66
77const processor = ( css , result ) => {
88 let imports = { }
9+
10+ // Find any declaration that supports imports
911 css . eachDecl ( declFilter , ( decl ) => {
1012 let matches = decl . value . match ( matchImports )
1113 if ( matches ) {
@@ -17,15 +19,18 @@ const processor = (css, result) => {
1719 decl . value = tmpSymbols . join ( ' ' )
1820 }
1921 } )
22+
23+ // If we've found any imports, insert :import rules
2024 Object . keys ( imports ) . forEach ( path => {
2125 let pathImports = imports [ path ]
2226 console . log ( pathImports )
2327 css . prepend ( postcss . rule ( {
2428 selector : `:import("${ path } ")` ,
25- nodes : Object . keys ( pathImports ) . map ( importedSymbol => {
26- return postcss . decl ( { prop : importedSymbol , value : pathImports [ importedSymbol ] } )
27- } )
28- } ) )
29+ nodes : Object . keys ( pathImports ) . map ( importedSymbol => postcss . decl ( {
30+ prop : importedSymbol ,
31+ value : pathImports [ importedSymbol ]
32+ } ) )
33+ } ) )
2934 } )
3035}
3136
You can’t perform that action at this time.
0 commit comments