Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vite:build-html] Cannot be closed: body #26

Open
jeff-fillmore opened this issue Nov 2, 2022 · 2 comments
Open

[vite:build-html] Cannot be closed: body #26

jeff-fillmore opened this issue Nov 2, 2022 · 2 comments

Comments

@jeff-fillmore
Copy link

Not sure what changed in 1.2.7 but now when building I'm getting error:

Error: Cannot be closed: body
    at ParseHTML.onCloseTagEndEvent (/Users/i868610/emarsys/campaign-blocks-client/node_modules/vite-plugin-html-env/lib/parse/index.js:313:15)
    at ParseHTML.parse (/Users/i868610/emarsys/campaign-blocks-client/node_modules/vite-plugin-html-env/lib/parse/index.js:189:16)
    at transform (/Users/i868610/emarsys/campaign-blocks-client/node_modules/vite-plugin-html-env/lib/index.js:141:19)
    at applyHtmlTransforms (file:///Users/i868610/emarsys/campaign-blocks-client/node_modules/vite/dist/node/chunks/dep-c842e491.js:44265:27)
    at Object.generateBundle (file:///Users/i868610/emarsys/campaign-blocks-client/node_modules/vite/dist/node/chunks/dep-c842e491.js:44185:32)
    at file:///Users/i868610/emarsys/campaign-blocks-client/node_modules/rollup/dist/es/shared/rollup.js:22748:40

If I remove the closing body tag than I get an error for the closing html tag:

Error: Cannot be closed: html
    at ParseHTML.onCloseTagEndEvent (/Users/i868610/emarsys/campaign-blocks-client/node_modules/vite-plugin-html-env/lib/parse/index.js:313:15)
    at ParseHTML.parse (/Users/i868610/emarsys/campaign-blocks-client/node_modules/vite-plugin-html-env/lib/parse/index.js:189:16)
    at transform (/Users/i868610/emarsys/campaign-blocks-client/node_modules/vite-plugin-html-env/lib/index.js:141:19)
    at applyHtmlTransforms (file:///Users/i868610/emarsys/campaign-blocks-client/node_modules/vite/dist/node/chunks/dep-c842e491.js:44265:27)
    at Object.generateBundle (file:///Users/i868610/emarsys/campaign-blocks-client/node_modules/vite/dist/node/chunks/dep-c842e491.js:44185:32)
    at file:///Users/i868610/emarsys/campaign-blocks-client/node_modules/rollup/dist/es/shared/rollup.js:22748:40

Not sure if this is meant to be but version 1.2.6 doesn't cause this error.

Thanks,

@mattgreenfield
Copy link

I have the same error but it's a div. Internal server error: Cannot be closed: div. By the process of elimination, it seems to be caused by an HTML comment inside a div.

<div>
      <!-- Remove this comment and the error goes away -->
</div>

If I move the comment up to be a direct child of the body I get Cannot be closed: body like you do.

I wonder if the issue is something todo with detecting < characters?

@jeff-fillmore
Copy link
Author

@mattgreenfield thank you. i move the comment to the head tag and it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants