Skip to content

Commit 3f850db

Browse files
authored
Merge pull request #9 from Kovensky/patch-2
fix(loader): Correctly preserve CSS module locals
2 parents 97c43d5 + 97c9a95 commit 3f850db

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/loader.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,10 @@ export function pitch(request) {
8787
if (!source) {
8888
return callback(new Error("Didn't get a result from child compiler"));
8989
}
90-
let text;
90+
let text, locals;
9191
try {
9292
text = exec(this, source, request);
93+
locals = text && text.locals;
9394
if (!Array.isArray(text)) {
9495
text = [[null, text]];
9596
} else {
@@ -108,8 +109,8 @@ export function pitch(request) {
108109
return callback(e);
109110
}
110111
let resultSource = '// extracted by mini-css-extract-plugin';
111-
if (text.locals && typeof resultSource !== 'undefined') {
112-
resultSource = `module.exports = ${JSON.stringify(text.locals)};`;
112+
if (locals && typeof resultSource !== 'undefined') {
113+
resultSource += `\nmodule.exports = ${JSON.stringify(locals)};`;
113114
}
114115

115116
return callback(null, resultSource);

0 commit comments

Comments
 (0)