Add @sveltejs/enhanced-img

#496

Issue

Open
B
benmccann
Mar 20, 2025, 11:47 PM

I had been holding off because I thought one of the issues might necessitate changing the API, but it looks like that's not necessary and things should be pretty stable now.

There's a webp and png in the demo app: https://github.com/sveltejs/cli/blob/d1f4432c0e31677ae754d50394547eeff820ddfe/packages/create/templates/demo/src/routes/%2Bpage.svelte#L3

We should just have the png and enhanced-img will generate the webp and avif automatically.

It would also be nice to add to the skeleton project as I think no one should be shipping unoptimized images. For the skeleton app, it potentially could be a question like:

What image optimization should be used?

  • build-time optimization with @sveltejs/enhanced-img
  • fetch from CDN with @unpic/svelte
  • none

Finally, I don't really like that images are currently stored in $lib/images. This seems like it will just become a huge unorganized catch-all. Images can live in the folder where they're used alongside the +page.svelte that includes them. This should help keep things a bit more organized. At least this was one of Rich's original arguments in favor of +page.svelte. But we don't really demonstrate that and guide users down that path today

👍 3

Info

Assignees None
Labels enhancement, pkg:create
Milestone None