Skip to content

Commit 5e45cf4

Browse files
lucgonplucasgontijopacto
authored andcommitted
fix(vite-dev-server): avoid leading whitespace when injecting loader
1 parent 3544244 commit 5e45cf4

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

npm/vite-dev-server/src/plugins/cypress.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,13 @@ export const Cypress = (
134134
newHtml = `${indexHtmlContent}
135135
<script>${loader}</script>`
136136
} else {
137-
// Insert before closing body tag
138-
newHtml = `
139-
${indexHtmlContent.substring(0, endOfBody)}
137+
// Insert before closing body tag without extra leading whitespace
138+
const beforeBody = indexHtmlContent.substring(0, endOfBody)
139+
const afterBody = indexHtmlContent.substring(endOfBody)
140+
141+
newHtml = `${beforeBody}
140142
<script>${loader}</script>
141-
${indexHtmlContent.substring(endOfBody)}
142-
`
143+
${afterBody}`
143144
}
144145

145146
return newHtml

0 commit comments

Comments
 (0)