Skip to content

Commit bb4892a

Browse files
fix: Adding css-loader v4 support (#40)
1 parent 908d491 commit bb4892a

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

index.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ const makeFileHandlers = filename => ({
6464
fs.writeFile(filename, content, { encoding: 'utf-8' }, handler)
6565
});
6666

67+
const extractLocalExports = (content) => {
68+
let localExports = content.split('exports.locals')[1];
69+
if (!localExports) {
70+
localExports = content.split('___CSS_LOADER_EXPORT___.locals')[1];
71+
}
72+
return localExports;
73+
}
74+
6775
module.exports = function(content, ...rest) {
6876
const { failed, success } = makeDoneHandlers(this.async(), content, rest);
6977

@@ -80,7 +88,7 @@ module.exports = function(content, ...rest) {
8088
let match;
8189
const cssModuleKeys = [];
8290

83-
const localExports = content.split('exports.locals')[1];
91+
const localExports = extractLocalExports(content);
8492

8593
while ((match = keyRegex.exec(localExports))) {
8694
if (cssModuleKeys.indexOf(match[1]) < 0) {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"@commitlint/cli": "^7.2.1",
3636
"commitizen": "^3.0.2",
3737
"commitlint-config-seek": "^1.0.0",
38-
"css-loader": "^1.0.0",
38+
"css-loader": "^4.2.1",
3939
"cz-conventional-changelog": "^2.1.0",
4040
"husky": "^1.1.2",
4141
"jest": "^24.7.1",

0 commit comments

Comments
 (0)