Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Sapper does not crawl img and source elements #1104

Closed
aloker opened this issue Feb 28, 2020 · 2 comments · Fixed by #1398
Closed

Sapper does not crawl img and source elements #1104

aloker opened this issue Feb 28, 2020 · 2 comments · Fixed by #1398

Comments

@aloker
Copy link
Contributor

aloker commented Feb 28, 2020

Is your feature request related to a problem? Please describe.
Sapper only follows links in <a> elements.

Describe the solution you'd like
Sapper should crawl links in the src and srcset attributes in <img> and <source> tags and export them to disk if they refer to server routes.

Describe alternatives you've considered
Manually copying the related files to the static directory, but that is not feasible when using Sapper for a headless CMS.

How important is this feature to you?
I'm developing a prototype frontend for a headless CMS and this is a huge problem. My server routes load the images from the CMS and transform them using sharp (resizing, type conversion etc for responsive images). Without this feature I cannot use the automatic conversion and implement an unrelated build step for this.

Additional context
PR #938 already proses a partial solution but I have a PR in the available that adds support for srcset attributes.

@artemjackson
Copy link
Contributor

Looks like It's a work for the bundler not for the Sapper itself. You may want to try @rollup/plugin-url or even svelte-image

@intrikate
Copy link

The bundler won’t handle dynamic paths. Nor can it process images coming from, say, imported .md files. Unless I’m missing something, without the crawler treating images (and other media) as first-class assets worth handling, a separate build phase is the only solution, and it’s a sad one indeed.

On the other hand, the joy of pointing your srcset to a server route and having everything built as part of the static export would be priceless.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants