Skip to content

Commit

Permalink
fix: Adding css-loader v4 support (seek-oss#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
takahirohonda committed Sep 22, 2020
1 parent 908d491 commit bb4892a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ const makeFileHandlers = filename => ({
fs.writeFile(filename, content, { encoding: 'utf-8' }, handler)
});

const extractLocalExports = (content) => {
let localExports = content.split('exports.locals')[1];
if (!localExports) {
localExports = content.split('___CSS_LOADER_EXPORT___.locals')[1];
}
return localExports;
}

module.exports = function(content, ...rest) {
const { failed, success } = makeDoneHandlers(this.async(), content, rest);

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

const localExports = content.split('exports.locals')[1];
const localExports = extractLocalExports(content);

while ((match = keyRegex.exec(localExports))) {
if (cssModuleKeys.indexOf(match[1]) < 0) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@commitlint/cli": "^7.2.1",
"commitizen": "^3.0.2",
"commitlint-config-seek": "^1.0.0",
"css-loader": "^1.0.0",
"css-loader": "^4.2.1",
"cz-conventional-changelog": "^2.1.0",
"husky": "^1.1.2",
"jest": "^24.7.1",
Expand Down

0 comments on commit bb4892a

Please sign in to comment.