diff --git a/lib/compile-vue.js b/lib/compile-vue.js index 2c0d595..35ab386 100644 --- a/lib/compile-vue.js +++ b/lib/compile-vue.js @@ -142,7 +142,10 @@ export function parseJs( let tmp = `style${Date.now()}` fixedStyle += `document.adoptedStyleSheets.push(${tmp})\n` - return `import ${tmp} from '${name}' assert { type: 'css' }\n${tmp}.path = '${name}'` + return `import ${tmp} from '${name}' assert { type: 'css' }\n${tmp}.path = '${name.replace( + /\\/g, + '\\\\' + )}'` } else { if (name.startsWith('@/')) { name = name.replace('@/', '/assets/js/') @@ -213,9 +216,9 @@ export function compileVue(file, imports, options = {}, isBuild) { js += ` let stylesheet = new CSSStyleSheet() -stylesheet.path = '${file.slice( - options.IS_MPA ? options.pagesDir.length : options.root.length - )}' +stylesheet.path = '${file + .slice(options.IS_MPA ? options.pagesDir.length : options.root.length) + .replace(/\\/g, '\\\\')}' stylesheet.replaceSync(\`${CACHE[file].css}\`) document.adoptedStyleSheets.push(stylesheet) ` diff --git a/package.json b/package.json index 878862e..3e7d9b5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@bytedo/vue-live", "type": "module", - "version": "0.1.1", + "version": "0.1.2", "bin": { "vue-live": "index.js" },