imagemin.ts 667 B

12345678910111213141516171819202122232425262728293031323334
  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. mozjpeg: {
  14. quality: 8,
  15. },
  16. pngquant: {
  17. quality: [0.8, 0.9],
  18. speed: 4,
  19. },
  20. svgo: {
  21. plugins: [
  22. {
  23. removeViewBox: false,
  24. },
  25. {
  26. removeEmptyAttrs: false,
  27. },
  28. ],
  29. },
  30. });
  31. return plugin;
  32. }