imagetools
imagetools copied to clipboard
Question: Is it possible to make sure the image output is always webp?
I want to make all of the images on my website webp. I don't want to constantly type ?webp'
behind the imports.
defaultDirectives
is exactly what you are looking for 👍
defaultDirectives
is exactly what you are looking for 👍
the doc doesn't look useful to me. where exactly do I put webp
? You need make the example more detailed
@wentallout i solve this in my sveltekit project like this:
// vite.config.ts
plugins: [
imagetools({
defaultDirectives: () => {
return new URLSearchParams({
format: 'webp'
})
}
})
]
and then i imported like this:
import image from '$lib/assets/image.png?&imagetools'
I don't know why i need to add ?&imagetools
but otherwise it does not work, i hope it helps you.
I don't know why i need to add ?&imagetools but otherwise it does not work, i hope it helps you.
Yeah, that seems like it's potentially a bug. It's coming from this line:
https://github.com/JonasKruckenberg/imagetools/blob/a5d1fb92b915e6b38925b363203aeed324d709cb/packages/vite/src/index.ts#L21