Skip to content

Commit 877e7d7

Browse files
committed
media query tests passing. Keeping the custom media defs in there because they will be processed per-file and don't actually get sent to the browser
1 parent 3c834f4 commit 877e7d7

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/index.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,18 @@ const processor = postcss.plugin('postcss-modules-scope', function(options) {
130130
});
131131
});
132132

133-
// Find any :local keyframes
134133
css.eachAtRule(atrule => {
134+
// Find any :local keyframes and rewrite them
135135
if(/keyframes$/.test(atrule.name)) {
136-
var localMatch = /^\s*:local\s*\((.+?)\)\s*$/.exec(atrule.params);
137-
if(localMatch) {
138-
atrule.params = exportScopedName(localMatch[1]);
136+
var localKeyFrames = /^\s*:local\s*\((.+?)\)\s*$/.exec(atrule.params);
137+
if(localKeyFrames) {
138+
atrule.params = exportScopedName(localKeyFrames[1]);
139+
}
140+
// Find any local() custom media, export them, but leave them as they are
141+
} else if (atrule.name === "custom-media") {
142+
var customMedia = /^\s*local\(([^\)]+)\)\s*(.*)$/.exec(atrule.params);
143+
if(customMedia) {
144+
exports[customMedia[1]] = [`"${customMedia[2]}"`];
139145
}
140146
}
141147
});
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
:export {
2-
--small: "(max-width: 30rem)";
1+
@custom-media local(--small) (max-width: 30rem);
2+
:export{
3+
--small: "(max-width: 30rem)"
34
}

0 commit comments

Comments
 (0)