withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
42.88k stars 2.24k forks source link

Asset links are not bundled in .html files #10928

Closed iainmerrick closed 2 weeks ago

iainmerrick commented 2 weeks ago

Astro Info

Astro                    v4.7.0
Node                     v20.6.1
System                   macOS (arm64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

I can add a .md file and the image files it uses into the pages directory and Astro does the right thing -- the images are imported as assets and the correct URL is generated.

However, I can't do this with .html files. Images referenced in an <img> tag are not imported and the URL isn't fixed up. The user just sees a broken image.

It would be good to be able to drop an existing, working HTML file into Astro and have it do the right thing.

What's the expected result?

Given a tag like this referencing a local image:

<img src="_foo.png">

I would expect the output to look like:

<img src="/_astro/_foo.123456.png">

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-uepn1b

Participation

Princesseuh commented 2 weeks ago

Not many people use HTML pages, but it'd still definitely be cool to support! I think this require some infrastructure though, as right now I don't believe we have an easy way to do this.

iainmerrick commented 2 weeks ago

I might have a poke around to see what would be involved. I'm pretty sure this works in Vite, and I thought Astro uses Vite under the hood, so it seems like it should be possible.

matthewp commented 2 weeks ago

For this feature request please start a discussion here: https://github.com/withastro/roadmap/discussions/new?category=proposal

HTML components are intentionally minimal and not processed in any way. See the docs for information on what is supported: https://docs.astro.build/en/basics/astro-components/#html-components

iainmerrick commented 1 week ago

Re-filed as a proposal: https://github.com/withastro/roadmap/discussions/915