Skip to content

Commit 16528d5

Browse files
committed
PostCSS 5 and CSS Modules updates
1 parent b6d12a4 commit 16528d5

File tree

2 files changed

+13
-34
lines changed

2 files changed

+13
-34
lines changed

lib/processCss.js

+9-30
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,7 @@ var parserPlugin = postcss.plugin("css-loader-parser", function(options) {
3131
return tokens.join("");
3232
}
3333

34-
function walkAtRules(a, b) {
35-
if(css.walkAtRules)
36-
css.walkAtRules(a, b);
37-
else
38-
css.eachAtRule(a, b);
39-
}
40-
41-
function walkRules(fn) {
42-
if(css.walkRules)
43-
css.walkRules(fn);
44-
else
45-
css.eachRule(fn);
46-
}
47-
48-
function walkDecls(fn) {
49-
if(css.walkDecls)
50-
css.walkDecls(fn);
51-
else
52-
css.eachDecl(fn);
53-
}
54-
55-
walkAtRules("import", function(rule) {
34+
css.walkAtRules("import", function(rule) {
5635
var values = Tokenizer.parseValues(rule.params);
5736
var url = values.nodes[0].nodes[0];
5837
if(url.type === "url") {
@@ -69,34 +48,34 @@ var parserPlugin = postcss.plugin("css-loader-parser", function(options) {
6948
url: url,
7049
mediaQuery: mediaQuery
7150
});
72-
rule.removeSelf();
51+
rule.remove();
7352
});
7453

75-
walkRules(function(rule) {
54+
css.walkRules(function(rule) {
7655
if(rule.selector === ":export") {
77-
rule.eachDecl(function(decl) {
56+
rule.walkDecls(function(decl) {
7857
exports[decl.prop] = decl.value;
7958
});
80-
rule.removeSelf();
59+
rule.remove();
8160
} else if(/^:import\(.+\)$/.test(rule.selector)) {
8261
var match = /^:import\((.+)\)$/.exec(rule.selector);
8362
var url = loaderUtils.parseString(match[1]);
84-
rule.eachDecl(function(decl) {
63+
rule.walkDecls(function(decl) {
8564
imports["$" + decl.prop] = importItems.length;
8665
importItems.push({
8766
url: url,
8867
export: decl.value
8968
});
9069
});
91-
rule.removeSelf();
70+
rule.remove();
9271
}
9372
});
9473

9574
Object.keys(exports).forEach(function(exportName) {
9675
exports[exportName] = replaceImportsInString(exports[exportName]);
9776
});
9877

99-
walkDecls(function(decl) {
78+
css.walkDecls(function(decl) {
10079
var values = Tokenizer.parseValues(decl.value);
10180
values.nodes.forEach(function(value) {
10281
value.nodes.forEach(function(item) {
@@ -124,7 +103,7 @@ var parserPlugin = postcss.plugin("css-loader-parser", function(options) {
124103
});
125104
decl.value = Tokenizer.stringifyValues(values);
126105
});
127-
walkAtRules(function(atrule) {
106+
css.walkAtRules(function(atrule) {
128107
if(typeof atrule.params === "string") {
129108
atrule.params = replaceImportsInString(atrule.params);
130109
}

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
"css-selector-tokenizer": "^0.5.1",
88
"cssnano": ">=2.6.1 <4",
99
"loader-utils": "~0.2.2",
10-
"postcss": ">=4.1.11 <6",
11-
"postcss-modules-extract-imports": "0.0.5",
12-
"postcss-modules-local-by-default": "0.0.12",
13-
"postcss-modules-scope": "0.0.8",
10+
"postcss": "^5.0.6",
11+
"postcss-modules-extract-imports": "1.0.0-beta2",
12+
"postcss-modules-local-by-default": "1.0.0-beta1",
13+
"postcss-modules-scope": "1.0.0-beta2",
1414
"source-list-map": "^0.1.4"
1515
},
1616
"devDependencies": {

0 commit comments

Comments
 (0)