imagemin.ts 722 B

1234567891011121314151617181920212223242526272829303132333435
  1. // 【图片压缩插件】
  2. // Image resource files used to compress the output of the production environment
  3. // https://github.com/anncwb/vite-plugin-imagemin
  4. import viteImagemin from 'vite-plugin-imagemin';
  5. export function configImageminPlugin() {
  6. const plugin = viteImagemin({
  7. gifsicle: {
  8. optimizationLevel: 7,
  9. interlaced: false,
  10. },
  11. optipng: {
  12. optimizationLevel: 7,
  13. },
  14. mozjpeg: {
  15. quality: 20,
  16. },
  17. pngquant: {
  18. quality: [0.8, 0.9],
  19. speed: 4,
  20. },
  21. svgo: {
  22. plugins: [
  23. {
  24. name: 'removeViewBox',
  25. },
  26. {
  27. name: 'removeEmptyAttrs',
  28. active: false,
  29. },
  30. ],
  31. },
  32. });
  33. return plugin;
  34. }