diff --git a/index.js b/index.js index 6da5e02..c1df2d3 100644 --- a/index.js +++ b/index.js @@ -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); @@ -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) { diff --git a/package.json b/package.json index a0f075a..d981618 100644 --- a/package.json +++ b/package.json @@ -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",