0

Is there any chance to convert images (jpg, png, ...) to webp format in Parceljs ? I can't find any Parceljs plugin for this action.

Arsen
  • 119
  • 2
  • 7

1 Answers1

1

For parcel v1 i also couldn't find a way.

For parcel v2 it should be planned, but its still beta and i couldn't get it to work with 2.0.0-beta.1.

Update: Got it working with latest nightly build.

Here is my upgrade path:

npm uninstall parcel-bundler
rm -rf node_modules package-lock.json
npm install sharp parcel@^2.0.0-nightly -D

It's described here: https://v2.parceljs.org/recipes/image/

In index.html i added a picture element:

<picture>
  <source src="url:./img/image.png?as=webp&width=350" type="image/webp" />
  <img src="url:./img/image.png?width=350" alt="..." width="350px" height="263px"/>
</picture>
ivoba
  • 5,780
  • 5
  • 48
  • 55