This commit is contained in:
masnn committed 2020-04-08 21:43:41 +08:00
1 parent 9c45527522
commit 7dc31d02fa
15 files changed
+10521 -3

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
/* eslint-disable */
import _ from 'lodash';
export default function mapWebpackUrlPrefix(mapList) {
const rules = mapList.map((mappingRule) => {
const regex = mappingRule.prefix.split('/').map(s => _.escapeRegExp(s)).join('[\\/\\\\]');
return {
from: new RegExp(`^${regex}`, mappingRule.flag),
to: mappingRule.replace,
};
});
return function mapUrl(url) {
rules.forEach((rule) => {
url = url.replace(rule.from, rule.to);
});
return url;
};
}