兼容国产辣鸡浏览器

pull/1/head 0.7.0
yutent 2023-04-25 11:12:27 +08:00
parent 5b3a976fd3
commit d80fd97601
3 changed files with 11 additions and 4 deletions

View File

@ -167,7 +167,11 @@ export function parseJs(
name = name.replace(/\.scss/, '.css') name = name.replace(/\.scss/, '.css')
} }
let tmp = `style${Date.now()}` let tmp = `style${Date.now()}`
fixedStyle += `document.adoptedStyleSheets.push(${tmp})\n` fixedStyle += `
let __sheets__ = [...document.adoptedStyleSheets]
__sheets__.push(${tmp})
document.adoptedStyleSheets = __sheets__
`
// 修正那反人类的windows路径 // 修正那反人类的windows路径
return `import ${tmp} from '${name}' assert { type: 'css' }\n${tmp}.path = '${name.replace( 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路径 // 修正那反人类的windows路径
output += ` output += `
let stylesheet = new CSSStyleSheet() let stylesheet = new CSSStyleSheet()
let __sheets__ = [...document.adoptedStyleSheets]
stylesheet.path = '${filename}' stylesheet.path = '${filename}'
stylesheet.replaceSync(\`${scss}\`) stylesheet.replaceSync(\`${scss}\`)
document.adoptedStyleSheets.push(stylesheet) __sheets__.push(stylesheet)
document.adoptedStyleSheets = __sheets__
` `
} }
if (scoped) { if (scoped) {

View File

@ -48,7 +48,8 @@ export const HMR_SCRIPT = `
let stylesheet = new CSSStyleSheet() let stylesheet = new CSSStyleSheet()
stylesheet.path = data.path stylesheet.path = data.path
stylesheet.replaceSync(data.content) stylesheet.replaceSync(data.content)
document.adoptedStyleSheets[i] = stylesheet tmp[i] = stylesheet
document.adoptedStyleSheets = tmp
break break
} }
} }

View File

@ -1,7 +1,7 @@
{ {
"name": "fite", "name": "fite",
"type": "module", "type": "module",
"version": "0.6.2", "version": "0.7.0",
"bin": { "bin": {
"fite": "index.js" "fite": "index.js"
}, },