VaJoy / vite-plugin-imagemin-lts

Forked from vite-plugin-imagemin with long-time-support.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

vite-plugin-imagemin-lts

English | 中文

A vite plugin for compressing image assets

Forked from vite-plugin-imagemin with long-time-support.

Install (yarn or npm)

node version: >=12.0.0

vite version: >=2.0.0

yarn add vite-plugin-imagemin-lts -D

or

npm i vite-plugin-imagemin-lts -D

Usage

  • Configuration plugin in vite.config.ts
import viteImagemin from 'vite-plugin-imagemin-lts'

export default () => {
  return {
    plugins: [
      viteImagemin({
        gifsicle: {
          optimizationLevel: 7,
          interlaced: false,
        },
        optipng: {
          optimizationLevel: 7,
        },
        mozjpeg: {
          quality: 20,
        },
        pngquant: {
          quality: [0.8, 0.9],
          speed: 4,
        },
        svgo: {
          plugins: [
            {
              name: 'removeViewBox',
            },
            {
              name: 'removeEmptyAttrs',
              active: false,
            },
          ],
        },
      }),
    ],
  }
}

Options

params type default default
verbose boolean true Whether to output the compressed result in the console
filter RegExp or (file: string) => boolean - Specify which resources are not compressed
disable boolean false Whether to disable
skipLargerFile boolean false Whether to skip larger processed file (while remainting the raw file)
svgo object or false - See Options
gifsicle object or false - See Options
mozjpeg object or false - See Options
optipng object or false - See Options
pngquant object or false - See Options
webp object or false - See Options

Develop

Install packages

cd packages/core && yarn install

Build

cd packages/core && yarn build

About

Forked from vite-plugin-imagemin with long-time-support.

License:MIT License


Languages

Language:TypeScript 88.4%Language:Vue 5.6%Language:Shell 3.6%Language:HTML 2.4%