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

[rollup-plugin-html] does not extract assets within <template> tags #2397

Open
WillsonSmith opened this issue Jul 22, 2023 · 0 comments
Open

Comments

@WillsonSmith
Copy link
Contributor

WillsonSmith commented Jul 22, 2023

When processing HTML the rollup-plugin-html plugin skips extracting assets within <template> tags.

I've made myself a small build system that uses @lit-labs/ssr to generate HTML pages and noticed that the image assets of a components were not being extracted. I've generated this minimal page as an example. The /public/img/me.png asset is not being extracted or included in the build.

I've also reproduced using a css asset.

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>My app</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    </head>
  <body>
    <!--lit-part S7bmmAfnsS0=-->
  <template>
    <img src="/public/img/me.png" />
  </template>
<!--/lit-part-->
  </body>
</html>

Hypothesis:
parse5 treats the contents of a <template> as a documentFragment and it only exists as content and does not exist in childNodes and when parse5-utils traverses childNodes it does not find the contents of a template.

parse5-utils using getChildNodes to traverse the document for assets.

const children = adapter.getChildNodes(/** @type {ParentNode} */ (node));

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

1 participant