Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: respect the localIdentRegExp option
  • Loading branch information
alexander-akait committed Jul 17, 2021
commit f0577739fd6801f689a7a67066cd6aee7525e4b6
14 changes: 13 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,19 @@ function defaultGetLocalIdent(
};

// eslint-disable-next-line no-underscore-dangle
return loaderContext._compilation.getPath(localIdentName, data);
let result = loaderContext._compilation.getPath(localIdentName, data);

if (options.regExp) {
const match = loaderContext.resourcePath.match(options.regExp);

if (match) {
match.forEach((matched, i) => {
result = result.replace(new RegExp(`\\[${i}\\]`, "ig"), matched);
});
}
}

return result;
}

function fixedEncodeURIComponent(str) {
Expand Down
Loading