I’m working on a React project using Vite as the build tool.
I’d like to automatically compress PNG and JPEG images when building for production, without changing the image import paths (so that imports like import logo from './logo.png' still work).
I tried using:
vite-plugin-imagemin→ works locally but fails in CI due to missing binaries.sharpin a custom script → changes file names, which breaks imports.
Goal:
Run during
vite buildMaintain image filenames and relative paths
Work on Linux CI runners (no GUI dependencies)
Question:
Is there a way to configure Vite (or another plugin) to compress images automatically during build while preserving the original filenames and paths?