Skip to content

Commit 920e374

Browse files
author
Alexander Grigoriev
committed
Support source maps
1 parent 5be0bef commit 920e374

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

index.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = function(content) {
1717
}
1818

1919
{
20-
let classes = getClasses(content);
20+
const classes = getClasses(content);
2121

2222
if (options.namedExport) {
2323
for (let c of classes) {
@@ -49,11 +49,20 @@ function getClasses(content) {
4949
/** @type {string[]} */
5050
let classes = [];
5151

52-
/** @type {RegExpExecArray} */
53-
let match;
54-
while (match = classesRegex.exec(content)) {
55-
if (classes.indexOf(match[1]) === -1) {
56-
classes.push(match[1]);
52+
// when `exportOnlyLocals` is on
53+
let from = content.indexOf('module.exports = {');
54+
// when `exportOnlyLocals` is off
55+
from = ~from ? from : content.indexOf('exports.locals = {');
56+
57+
if (~from) {
58+
content = content.substr(from);
59+
60+
/** @type {RegExpExecArray} */
61+
let match;
62+
while (match = classesRegex.exec(content)) {
63+
if (classes.indexOf(match[1]) === -1) {
64+
classes.push(match[1]);
65+
}
5766
}
5867
}
5968

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dts-css-modules-loader",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "webpack loader to generate typings for css modules",
55
"dependencies": {
66
"loader-utils": "^1.2.0"
@@ -10,9 +10,10 @@
1010
},
1111
"keywords": [
1212
"css-modules",
13+
"typescript",
1314
"typings",
14-
"loader",
15-
"webpack"
15+
"webpack",
16+
"loader"
1617
],
1718
"license": "MIT",
1819
"homepage": "https://github.com/Megaputer/dts-css-modules-loader"

0 commit comments

Comments
 (0)