Skip to content

Commit 9ec73e0

Browse files
committed
fix loader
1 parent 18a794f commit 9ec73e0

File tree

3 files changed

+66
-14
lines changed

3 files changed

+66
-14
lines changed

packages/veui-loader/lib/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function patchComponent(content, component, options, resolve) {
8989

9090
return Object.keys(parts).reduce(function (content, type) {
9191
return parts[type].reduce(function (content, peerPath) {
92-
return patchType(content, type, (0, _utils.normalize)(peerPath));
92+
return patchType(content, type, peerPath);
9393
}, content);
9494
}, content);
9595
}
@@ -109,19 +109,20 @@ function getExtname(file) {
109109
var RE_SCRIPT = /<script(?:\s+[^>]*)?>/i;
110110

111111
function patchType(content, type, peerPath) {
112+
var normalizedPath = (0, _utils.normalize)(peerPath).replace(/\\/g, '\\\\');
112113
switch (type) {
113114
case 'script':
114115
content = content.replace(RE_SCRIPT, function (match) {
115-
return match + '\nimport \'' + peerPath + '\'\n';
116+
return match + '\nimport \'' + normalizedPath + '\'\n';
116117
});
117118
break;
118119
case 'style':
119120
var langStr = '';
120-
var ext = getExtname(peerPath);
121+
var ext = getExtname(normalizedPath);
121122
if (ext !== 'css') {
122123
langStr = 'lang="' + ext + '" ';
123124
}
124-
content += '\n<style ' + langStr + 'src="' + peerPath + '"></style>\n';
125+
content += '\n<style ' + langStr + 'src="' + normalizedPath + '"></style>\n';
125126
break;
126127
default:
127128
break;

packages/veui-loader/package-lock.json

Lines changed: 60 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/veui-loader/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ const RE_SCRIPT = /<script(?:\s+[^>]*)?>/i
114114
* @returns {string} The patched content
115115
*/
116116
function patchType (content, type, peerPath) {
117-
let normalizedPath = normalize(peerPath)
117+
let normalizedPath = normalize(peerPath).replace(/\\/g, '\\\\')
118118
switch (type) {
119119
case 'script':
120120
content = content.replace(RE_SCRIPT, match => {

0 commit comments

Comments
 (0)