Skip to content

Commit 45c72b3

Browse files
committed
Merge pull request #6 from timdorr/master
Update to PostCSS 5.x
2 parents b297a4b + 1071b1e commit 45c72b3

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
},
3535
"homepage": "https://github.com/css-modules/postcss-modules-extract-imports",
3636
"dependencies": {
37-
"postcss": "^4.1.11"
37+
"postcss": "^5.0.4"
3838
},
3939
"devDependencies": {
4040
"babel": "^5.4.7",

src/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const processor = postcss.plugin( 'modules-extract-imports', function ( options
1212
createImportedName = options && options.createImportedName || (( importName/*, path*/ ) => `i__imported_${importName.replace( /\W/g, '_' )}_${importIndex++}`);
1313

1414
// Find any declaration that supports imports
15-
css.eachDecl( declFilter, ( decl ) => {
15+
css.walkDecls( declFilter, ( decl ) => {
1616
let matches = decl.value.match( matchImports );
1717
if ( matches ) {
1818
let [/*match*/, symbols, doubleQuotePath, singleQuotePath] = matches;
@@ -31,7 +31,7 @@ const processor = postcss.plugin( 'modules-extract-imports', function ( options
3131

3232
// If we've found any imports, insert or append :import rules
3333
let existingImports = {};
34-
css.eachRule(rule => {
34+
css.walkRules(rule => {
3535
let matches = icssImport.exec(rule.selector);
3636
if (matches) {
3737
let [/*match*/, doubleQuotePath, singleQuotePath] = matches;
@@ -40,19 +40,20 @@ const processor = postcss.plugin( 'modules-extract-imports', function ( options
4040
});
4141

4242
Object.keys( imports ).reverse().forEach( path => {
43+
4344
let rule = existingImports[path];
4445
if (!rule) {
4546
rule = postcss.rule( {
4647
selector: `:import("${path}")`,
47-
after: "\n"
48+
raws: { after: "\n" }
4849
} );
4950
css.prepend( rule );
5051
}
5152
Object.keys( imports[path] ).forEach( importedSymbol => {
5253
rule.push(postcss.decl( {
5354
value: importedSymbol,
5455
prop: imports[path][importedSymbol],
55-
before: "\n ",
56+
raws: { before: "\n " },
5657
_autoprefixerDisabled: true
5758
} ) );
5859
} );

0 commit comments

Comments
 (0)