withastro / starlight

🌟 Build beautiful, accessible, high-performance documentation websites with Astro
https://starlight.astro.build
MIT License
4.54k stars 490 forks source link

webp animation not works in assets #186

Closed RamaTrujillo closed 1 year ago

RamaTrujillo commented 1 year ago

What version of starlight are you using?

0.1.2

What version of astro are you using?

2.6.2

What package manager are you using?

pnpm

What operating system are you using?

Linux

What browser are you using?

Chrome

Describe the Bug

When whe try to compile an image in a .md file, the WEBP animation image does not work propely and crash the dev server with this error: [UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "Cannot read properties of null (reading 'data')".] { code: 'ERR_UNHANDLED_REJECTION' }

Link to Minimal Reproducible Example

https://codesandbox.io/p/sandbox/github/PabloBagliere/example-error-astro/tree/main

Participation

delucis commented 1 year ago

Thanks for the report! I think we can fix this with the next minor release. We’re going to switch Starlight to use Sharp instead of Squoosh for image optimisation, and I just tested and looks like Sharp handles this animated WebP successfully — very useful to have that as a test case.

Will report back here once we fix this, but if you follow this “Using Sharp” guide in the Astro docs, that should unblock you for now: https://docs.astro.build/en/guides/assets/#using-sharp

delucis commented 1 year ago

Sharp needs to be a direct dependency of projects, so I’m not able to enable it by default in the next release as I hoped, but I still recommend switching to it. I added Sharp to the starter template so new projects will get it by default, but existing projects will need to enable it manually.

There is a full guide in Astro’s docs on how to enable Sharp. Let me know if you still see any issues!