Choosing esbuild vs Terser minification in Vite for latency‑sensitive builds
0 reputation · 20 Feb 2023, 20:42 UTC
The goal is to shorten Vite production build times without sacrificing the ability to run the output in browsers that require ES5‑compatible code.
Using build.minify: 'esbuild' leverages esbuild’s fast parsing and minification, but it may not apply the same level of TypeScript‑specific transforms or aggressive tree‑shaking that Terser provides, potentially affecting bundle size and source‑map fidelity. The safer default build.minify: 'terser' guarantees broad compatibility but increases build latency, which can be noticeable in large codebases or CI pipelines.
Which minifier delivers an acceptable bundle size for ES5 targets while preserving source maps? How does the build‑time difference affect CI workflows? Are there any known limitations of esbuild minification with the current Vite version that would require fallback to Terser?