11ty / webc

Single File Web Components
MIT License
1.3k stars 36 forks source link

`<link rel="stylesheet">` elements generated in `webc:for` are removed for bundling but not part of the bundle #188

Open riskygit opened 11 months ago

riskygit commented 11 months ago

Compiling <link webc:for="href of stylesheets" rel="stylesheet" :href="href"> shows the css files are found, the element is removed from the HTML output, but the default bundle is missing the CSS.

<template webc:if="stylesheets" webc:nokeep>
  <link webc:for="href of stylesheets" rel="stylesheet" :href="href">
</template>

^ This is also not working... same issue; HTML is excised, but CSS is not bundled.

<script webc:type="js">
  if (Array.isArray(stylesheets)) {
    stylesheets.map(href => `<link rel="stylesheet" href="${href}">`).join("");
  }
</script>

^ Edit: This works... isn't this also implicitly a template? I don't know why this would work and not the other.