imagemin.ts 695 B

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