imagemin.ts 707 B

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