1.0.14 • Published 10 months ago

vite-plugin-image-to-webp v1.0.14

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
10 months ago

vite-plugin-image-to-webp

npm

A very basic vite plugin which will, when building, find all .jpeg, .jpg, and .png images, convert them to .webp and then adjust the image urls accordingly.

 

Usage

vite.config.ts

import { imageToWebpPlugin } from 'vite-plugin-image-to-webp'

export default {
  plugins: [
    imageToWebpPlugin(),
  ]
}

Options

There are also a limited number of options for the image conversion.

vite.config.ts

import { imageToWebpPlugin } from 'vite-plugin-image-to-webp'

// default options
export default {
  plugins: [
    imageToWebpPlugin({
      imageFormats: ['jpg', 'jpeg', 'png'],
      webpQuality: {},
      destinationFolder: 'dist',
    }),
  ]
}

Logs

When building, logs show which images have been converted and their old and new file sizes: npm.io

Motivation

Even though webp is probably the best image format for the web, most images are exported as png or jpeg. With this plugin we can still use these image files and the build process will convert the files automatically.

1.0.14

10 months ago

1.0.13

10 months ago

1.0.12

10 months ago

1.0.10

11 months ago

1.0.9

11 months ago

1.0.8

11 months ago

1.0.7

11 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.0

11 months ago