mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
fix: inline global css that's not at beginning of line (#141)
This commit is contained in:
parent
eae6c55bae
commit
f650a70197
@ -87,7 +87,13 @@ export const RenderPlugin = () => {
|
||||
return `\${${r.slice(2, -2)}}`.replace(/messages\./g, 'props.')
|
||||
})
|
||||
const styleContent = Array.from(html.matchAll(/<style[^>]*>([\s\S]*?)<\/style>/g)).map(block => block[1]).join('\n')
|
||||
const globalStyles = styleContent.match(/^([^.][^{]*\{[^}]*\})*/)?.[0]
|
||||
const globalStyles = styleContent.replace(/(\.[^{]*\{[^}]*\})+.?/g, (r) => {
|
||||
const lastChar = r[r.length - 1]
|
||||
if (lastChar && !['}', '.', '@', '*', ':'].includes(lastChar)) {
|
||||
return ';' + lastChar
|
||||
}
|
||||
return lastChar
|
||||
}).replace(/@media[^{]*\{\}/g, '')
|
||||
const inlineScripts = Array.from(html.matchAll(/<script>([\s\S]*?)<\/script>/g))
|
||||
.map(block => block[1])
|
||||
.filter(i => !i.includes('const t=document.createElement("link")'))
|
||||
|
Loading…
Reference in New Issue
Block a user