mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +00:00
fix(templates): adjust style extraction regexp (#153)
This commit is contained in:
parent
e4983351ba
commit
8caa2ccb95
@ -87,13 +87,13 @@ export const RenderPlugin = () => {
|
|||||||
return `\${${r.slice(2, -2)}}`.replace(/messages\./g, 'props.')
|
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 styleContent = Array.from(html.matchAll(/<style[^>]*>([\s\S]*?)<\/style>/g)).map(block => block[1]).join('\n')
|
||||||
const globalStyles = styleContent.replace(/(\.[^{]*\{[^}]*\})+.?/g, (r) => {
|
const globalStyles = styleContent.replace(/(\.[^{\d][^{]*?\{[^}]*?\})+.?/g, (r) => {
|
||||||
const lastChar = r[r.length - 1]
|
const lastChar = r[r.length - 1]
|
||||||
if (lastChar && !['}', '.', '@', '*', ':'].includes(lastChar)) {
|
if (lastChar && !['}', '.', '@', '*', ':'].includes(lastChar)) {
|
||||||
return ';' + lastChar
|
return ';' + lastChar
|
||||||
}
|
}
|
||||||
return lastChar
|
return lastChar
|
||||||
}).replace(/@media[^{]*\{\}/g, '')
|
}).replace(/@media[^{]*?\{\}/g, '')
|
||||||
const inlineScripts = Array.from(html.matchAll(/<script>([\s\S]*?)<\/script>/g))
|
const inlineScripts = Array.from(html.matchAll(/<script>([\s\S]*?)<\/script>/g))
|
||||||
.map(block => block[1])
|
.map(block => block[1])
|
||||||
.filter(i => !i.includes('const t=document.createElement("link")'))
|
.filter(i => !i.includes('const t=document.createElement("link")'))
|
||||||
|
Loading…
Reference in New Issue
Block a user