Skip to content

yjl9903/vuepress-plugin-imagemin

 
 

Repository files navigation

vuepress-plugin-imagemin

This repo is forked and modified from vite-plugin-imagemin.

A VuePress plugin for compressing image assets

Install

npm i vuepress-plugin-imagemin -D

Usage

Configuration plugin in .vuepress/config.ts

import { defineUserConfig } from 'vuepress';
import Imagemin from 'vuepress-plugin-imagemin'

export default defineUserConfig({
  plugins: [
    Imagemin({
      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
include RegExp or RegExp[] - Specify which resources are compressed
exclude RegExp or RegExp[] - Specify which resources are not compressed
disable boolean false Whether to disable
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

Run Example

npm run dev:play
npm run dev:build

License

MIT

Inspiration