diff --git a/packages/vite/src/node/plugins/html.ts b/packages/vite/src/node/plugins/html.ts index 8e316b6709f0d4..1d3f45f6f74b52 100644 --- a/packages/vite/src/node/plugins/html.ts +++ b/packages/vite/src/node/plugins/html.ts @@ -545,7 +545,7 @@ function injectToHead( } else { // inject before head close if (headInjectRE.test(html)) { - return html.replace(headInjectRE, `${tagsHtml}\n$&`) + return html.replace(headInjectRE, `${tagsHtml}\n $&`) } } // if no tag is present, just prepend @@ -592,7 +592,7 @@ function serializeTags(tags: HtmlTagDescriptor['children']): string { if (typeof tags === 'string') { return tags } else if (tags) { - return tags.map(serializeTag).join(`\n `) + return ` ${tags.map(serializeTag).join('\n ')}` } return '' }