You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bundling images (and I assume other assets) does not work when they are imported in html template elements.
It works when I write <img src="./my-asset.svg"/> in the body, I can see the asset copied in the distant directory (or inlined) and the source url changed accordingly. But when my <img/> is in a <template> element, the url does not change and the asset is not bundled.
(can reproduce using bun, pnpm and npm, haven't tested yarn)
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
Seems like template nodes' children are not inserted into node.childNodes but node.content.childNodes. As the html parser only traverses node.childNodes (1) template children are skipped. I don't know if this behaviour is intentional.
If not I'd love to contribute.
Describe the bug
Bundling images (and I assume other assets) does not work when they are imported in html template elements.
It works when I write
<img src="./my-asset.svg"/>
in the body, I can see the asset copied in the distant directory (or inlined) and the source url changed accordingly. But when my<img/>
is in a<template>
element, the url does not change and the asset is not bundled.(can reproduce using bun, pnpm and npm, haven't tested yarn)
Reproduction
https://stackblitz.com/edit/vitejs-vite-9jcjwh?file=index.html&terminal=dev
Steps to reproduce
Run
npm run build
and look at the generated html indist/index.html
.System Info
In stackblitz:
On my local machine:
Used Package Manager
pnpm
Logs
Click to expand!
Validations
The text was updated successfully, but these errors were encountered: