Blame view

build/vite/plugin/imagemin.ts 695 Bytes
vben authored
1
// Image resource files used to compress the output of the production environment
2
// https://github.com/anncwb/vite-plugin-imagemin
vben authored
3
4
5
6
7
8
9
10
11
12
13
14
15
import viteImagemin from 'vite-plugin-imagemin';

export function configImageminPlugin() {
  const plugin = viteImagemin({
    gifsicle: {
      optimizationLevel: 7,
      interlaced: false,
    },
    optipng: {
      optimizationLevel: 7,
    },
    mozjpeg: {
16
      quality: 20,
17
18
    },
    pngquant: {
19
      quality: [0.8, 0.9],
20
21
22
23
24
      speed: 4,
    },
    svgo: {
      plugins: [
        {
25
          name: 'removeViewBox',
26
27
        },
        {
28
29
          name: 'removeEmptyAttrs',
          active: false,
30
31
32
33
34
35
        },
      ],
    },
  });
  return plugin;
}