Skip to content

Commit 2d988d3

Browse files
authored
Update index.js
1 parent 66256af commit 2d988d3

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module.exports = function (css, resourcePath, aliases) {
1212
return css;
1313

1414
function resolve(url, resourcePath) {
15+
1516
for (var aliasName in aliases) {
1617
var regExp = new RegExp('^' + aliasName + '(.*)')
1718

@@ -24,24 +25,31 @@ module.exports = function (css, resourcePath, aliases) {
2425
}
2526

2627
function parse(css, regex) {
27-
var m, importOriginal, importReplace;
28+
var m, importOriginal, importReplace, replace = [];
2829

2930
while ((m = regex.exec(css)) !== null) {
3031
if (m.index === regex.lastIndex) {
3132
regex.lastIndex++;
3233
}
3334

35+
replace.push(m);
36+
}
37+
38+
for (var item in replace) {
39+
var m = replace[item];
40+
3441
importOriginal = '';
3542
importReplace = '';
3643
var mathGroups = m.groups();
44+
3745
for (var groupName in mathGroups) {
3846
var match = mathGroups[groupName];
3947
importOriginal += typeof match !== 'undefined' ? match : '';
4048

4149
if (groupName !== 'url') {
4250
importReplace += typeof match !== 'undefined' ? match : '';
4351
} else {
44-
importReplace += resolve(match, '.');
52+
importReplace += resolve(match, resourcePath);
4553
}
4654
}
4755

0 commit comments

Comments
 (0)