From d80fd976019a2c40ce0f0a8d134aee8eb41417d2 Mon Sep 17 00:00:00 2001 From: yutent Date: Tue, 25 Apr 2023 11:12:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E5=9B=BD=E4=BA=A7=E8=BE=A3?= =?UTF-8?q?=E9=B8=A1=E6=B5=8F=E8=A7=88=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/compile-vue.js | 10 ++++++++-- lib/constants.js | 3 ++- package.json | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/compile-vue.js b/lib/compile-vue.js index 802fb70..6e39619 100644 --- a/lib/compile-vue.js +++ b/lib/compile-vue.js @@ -167,7 +167,11 @@ export function parseJs( name = name.replace(/\.scss/, '.css') } let tmp = `style${Date.now()}` - fixedStyle += `document.adoptedStyleSheets.push(${tmp})\n` + fixedStyle += ` + let __sheets__ = [...document.adoptedStyleSheets] + __sheets__.push(${tmp}) + document.adoptedStyleSheets = __sheets__ + ` // 修正那反人类的windows路径 return `import ${tmp} from '${name}' assert { type: 'css' }\n${tmp}.path = '${name.replace( @@ -277,9 +281,11 @@ export function compileVue(file, imports, options = {}, isBuild) { // 修正那反人类的windows路径 output += ` let stylesheet = new CSSStyleSheet() +let __sheets__ = [...document.adoptedStyleSheets] stylesheet.path = '${filename}' stylesheet.replaceSync(\`${scss}\`) -document.adoptedStyleSheets.push(stylesheet) +__sheets__.push(stylesheet) +document.adoptedStyleSheets = __sheets__ ` } if (scoped) { diff --git a/lib/constants.js b/lib/constants.js index 2e943d6..770bb1d 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -48,7 +48,8 @@ export const HMR_SCRIPT = ` let stylesheet = new CSSStyleSheet() stylesheet.path = data.path stylesheet.replaceSync(data.content) - document.adoptedStyleSheets[i] = stylesheet + tmp[i] = stylesheet + document.adoptedStyleSheets = tmp break } } diff --git a/package.json b/package.json index 303f8ea..c5316a6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "fite", "type": "module", - "version": "0.6.2", + "version": "0.7.0", "bin": { "fite": "index.js" },