@@ -12,7 +12,7 @@ const processor = postcss.plugin( 'modules-extract-imports', function ( options
12
12
createImportedName = options && options . createImportedName || ( ( importName /*, path*/ ) => `i__imported_${ importName . replace ( / \W / g, '_' ) } _${ importIndex ++ } ` ) ;
13
13
14
14
// Find any declaration that supports imports
15
- css . eachDecl ( declFilter , ( decl ) => {
15
+ css . walkDecls ( declFilter , ( decl ) => {
16
16
let matches = decl . value . match ( matchImports ) ;
17
17
if ( matches ) {
18
18
let [ /*match*/ , symbols , doubleQuotePath , singleQuotePath ] = matches ;
@@ -31,7 +31,7 @@ const processor = postcss.plugin( 'modules-extract-imports', function ( options
31
31
32
32
// If we've found any imports, insert or append :import rules
33
33
let existingImports = { } ;
34
- css . eachRule ( rule => {
34
+ css . walkRules ( rule => {
35
35
let matches = icssImport . exec ( rule . selector ) ;
36
36
if ( matches ) {
37
37
let [ /*match*/ , doubleQuotePath , singleQuotePath ] = matches ;
@@ -40,19 +40,20 @@ const processor = postcss.plugin( 'modules-extract-imports', function ( options
40
40
} ) ;
41
41
42
42
Object . keys ( imports ) . reverse ( ) . forEach ( path => {
43
+
43
44
let rule = existingImports [ path ] ;
44
45
if ( ! rule ) {
45
46
rule = postcss . rule ( {
46
47
selector : `:import("${ path } ")` ,
47
- after : "\n"
48
+ raws : { after : "\n" }
48
49
} ) ;
49
50
css . prepend ( rule ) ;
50
51
}
51
52
Object . keys ( imports [ path ] ) . forEach ( importedSymbol => {
52
53
rule . push ( postcss . decl ( {
53
54
value : importedSymbol ,
54
55
prop : imports [ path ] [ importedSymbol ] ,
55
- before : "\n " ,
56
+ raws : { before : "\n " } ,
56
57
_autoprefixerDisabled : true
57
58
} ) ) ;
58
59
} ) ;
0 commit comments