Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/cijiugechu/vite-plugin-thumbhash

Bring ThumbHash to your vite project.
https://github.com/cijiugechu/vite-plugin-thumbhash

image image-processing napi-rs thumbhash thumbnail vite vite-plugin

Last synced: 8 days ago
JSON representation

Bring ThumbHash to your vite project.

Awesome Lists containing this project

README

        

# `vite-plugin-thumbhash`

Add [ThumbHash](https://github.com/evanw/thumbhash) to your vite project.

## Install

```shell
npm install vite-plugin-thumbhash --save-dev
```

```shell
pnpm add vite-plugin-thumbhash -D
```

## Usage

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

export default defineConfig({
plugins: [thumbHash()]
})
```

```jsx
import Image from 'example.jpg?thumb'

//...

// If you want to import original image

```

## TypeScript IntelliSense

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

## Options

```ts
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
/**
* A picomatch pattern, or array of patterns,
* which specifies the files in the build the plugin should ignore.
*/
exclude?: Array | string | RegExp
/**
* type OutputExtension = 'png' | 'jpg' | 'webp' | 'avif'
* @default: 'png'
*/
outputExtension?: OutputExtension
}
```

## Example

see [playground](/packages/playground/)

## License

MIT © [nemurubaka](https://github.com/cijiugechu)