Skip to content

Commit f057773

Browse files
fix: respect the localIdentRegExp option
1 parent 9560168 commit f057773

File tree

3 files changed

+172
-15210
lines changed

3 files changed

+172
-15210
lines changed

src/utils.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,19 @@ function defaultGetLocalIdent(
387387
};
388388

389389
// eslint-disable-next-line no-underscore-dangle
390-
return loaderContext._compilation.getPath(localIdentName, data);
390+
let result = loaderContext._compilation.getPath(localIdentName, data);
391+
392+
if (options.regExp) {
393+
const match = loaderContext.resourcePath.match(options.regExp);
394+
395+
if (match) {
396+
match.forEach((matched, i) => {
397+
result = result.replace(new RegExp(`\\[${i}\\]`, "ig"), matched);
398+
});
399+
}
400+
}
401+
402+
return result;
391403
}
392404

393405
function fixedEncodeURIComponent(str) {

0 commit comments

Comments
 (0)