0.6.1 • Published 1 year ago

rollup-plugin-napi-image v0.6.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

rollup-plugin-napi-image

Rollup plugin for optimizing images powered by @napi-rs/image, without involving node-gyp.

see example

Usage

1. install

npm install rollup-plugin-napi-image --save-dev
# or you use pnpm
pnpm add  rollup-plugin-napi-image -D

2. add plugin to your config file

  • if you are using rollup, import this plugin and add to plugins field like following:
import { defineConfig } from 'rollup'
import { napiImage } from 'rollup-plugin-napi-image'
// ... other lines

export default defineConfig({
  plugins: [
    /* other plugins */
    napiImage({
      mode: 'lossy',
      quality: 75,
    }),
  ],
})
  • if you are using vite , just replace the first line of above with import { defineConfig } from 'vite'

3. options

nametypedefaultdescription
includeRegExp \| string \| Array<string \| RegExp>nullA picomatch pattern, or array of patterns, which specifies the files in the build the plugin should operate on. By default all supported images are targeted.
excludeRegExp \| string \| Array<string \| RegExp>nullA picomatch pattern, or array of patterns, which specifies the files in the build the plugin should ignore. By default no images are ignored.
mode'lossy' \| 'lossless'The optimization mode applied to images, when mode is lossy , you can specify quality for the process.
qualitynumber75Only works when mode is lossy.
toModernExt(ext: SupportedExt) => ModernExtext => extA conversion function that converts the specified image format to a modern image format.

4. supported formats

  1. jpg/jpeg
  2. png
  3. webp
  4. avif

License

MIT © nemurubaka

0.4.5

1 year ago

0.4.4

1 year ago

0.4.6

1 year ago

0.5.0

1 year ago

0.6.1

1 year ago

0.6.0

1 year ago

0.5.1

1 year ago

0.4.3

1 year ago

0.4.2

1 year ago

0.4.1

1 year ago

0.4.0

1 year ago

0.3.1

1 year ago

0.3.0

1 year ago

0.2.0

1 year ago

0.1.0

1 year ago