fix(nuxt): include tag attrs for non self-closing tags in tree-shake regex (#6675)

Co-authored-by: Daniel Roe <daniel@roe.dev>
This commit is contained in:
Julien Huang 2022-08-16 15:22:10 +02:00 committed by GitHub
parent 49acae5f02
commit a3a8706e43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,7 +35,7 @@ export const TreeShakeTemplatePlugin = createUnplugin((options: TreeShakeTemplat
const s = new MagicString(code)
// Do not render client-only slots on SSR, but preserve attributes
s.replace(COMPONENTS_RE, r => r.replace(/<([^ >]*)[ >][\s\S]*$/, '<$1 />'))
s.replace(COMPONENTS_RE, r => r.replace(/<([^>]*[^/])\/?>[\s\S]*$/, '<$1 />'))
if (s.hasChanged()) {
return {