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" },