jw-12138 / vite-plugin-vsharp

Compress Images for the Web with Vite and Sharp
MIT License
43 stars 0 forks source link

Add resize support #6

Closed septatrix closed 1 year ago

septatrix commented 1 year ago

It does not seem like it is currently supported. However, it would be really great to use. This way one can add the full res images and limit the output resolution without having to resize them beforehand manually.

jw-12138 commented 1 year ago

@septatrix thanks for the advice, I'll give it a look!

jw-12138 commented 1 year ago

https://www.npmjs.com/package/vite-plugin-vsharp/v/1.2.0

@septatrix vite-plugin-vsharp version 1.2.0 has added image resizing support, you can use it like this:

// vite.config.js

import vsharp from "vite-plugin-vsharp"

export default ({
  plugins: [
    vsharp({
      width: 800,
      height: 800,
      scale: 0.8
    })
  ]
})

note that scale will overwrite both width and height property.