0.1.6 • Published 9 months ago

vite-plugin-thumbhash v0.1.6

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

vite-plugin-thumbhash

Add ThumbHash to your vite project.

Install

npm install vite-plugin-thumbhash --save-dev
pnpm add vite-plugin-thumbhash -D

Usage

import { defineConfig } from 'vite'
import { thumbHash } from 'vite-plugin-thumbhash'

export default defineConfig({
  plugins: [thumbHash()]
})
import Image from 'example.jpg?thumb'

//...
<img src={Image.thumbSrc}
     width={Image.thumbWidth}
     height={Image.thumbHeight}
/>


// If you want to import original image
<img src={Image.originalSrc}
     width={Image.originalWidth}
     height={Image.originalHeight}
/>

TypeScript IntelliSense

Add the following code to vite-env.d.ts :

/// <reference types="vite-plugin-thumbhash/client" />

Options

type Options =
    {
      /**
       * A picomatch pattern, or array of patterns, 
       * which specifies the files in the build the plugin should operate on. 
       */
      include?: Array<string | RegExp> | string | RegExp
      /**
       * A picomatch pattern, or array of patterns,
       * which specifies the files in the build the plugin should ignore.
       */
      exclude?: Array<string | RegExp> | string | RegExp
      /**
       * type OutputExtension = 'png' | 'jpg' | 'webp' | 'avif'
       * @default: 'png'
       */
      outputExtension?: OutputExtension
    }

Example

see playground

License

MIT © nemurubaka

0.1.6

9 months ago

0.1.5

11 months ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago