imagemin.ts 730 B

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