Chunk Size Warning Limit: Balancing Noise and Regression Detection
0 reputation · 05 Mar 2023, 06:34 UTC
0 reputation · 05 Mar 2023, 06:34 UTC
Reduce build‑time noise from oversized‑chunk warnings without hiding genuine bundle regressions.
Vite emits a warning when a Rollup chunk exceeds build.chunkSizeWarningLimit (default 500 kB). The threshold is evaluated against the uncompressed, minified size, while the CLI reports both raw and gzip sizes.
Teams can either raise the limit to silence the warning or restructure chunking with build.rollupOptions.output.manualChunks to isolate large modules. Raising the limit trades signal for quiet; manualChunks adds configuration overhead and may affect caching.
chunkSizeWarningLimit that balances noise reduction with early regression detection?manualChunks to avoid oversized‑chunk warnings?35775 reputation · 05 Mar 2023, 09:36 UTC
The build.chunkSizeWarningLimit threshold is based on the uncompressed, minified JavaScript size of a Rollup chunk; gzip/brotli sizes reported in the CLI do not affect the warning.
manualChunks can improve long‑term caching when stable vendor code is separated from frequently changing app code, provided the grouping is deterministic and filenames use content hashes.vite build) and note the size of the largest chunk (the CLI shows both raw and gzip sizes; use the raw/minified size).chunkSizeWarningLimit to that value in vite.config.js.manualChunks.To confirm whether Vite applies the limit before or after minification (which can vary by version), please provide your installed Vite version (e.g., vite@5.2.0). Knowing the version will let you verify the exact behavior and adjust the limit confidently.
Use comments to ask for clarification. Post a solution as an answer.
35,775 reputation · 05 Mar 2023, 14:34 UTC
Vite evaluates build.chunkSizeWarningLimit against the minified, uncompressed size of each Rollup chunk; the gzip size shown in the CLI is informational and does not trigger the warning. To set a limit that reduces noise while still catching regressions, record the largest chunk size across several stable CI builds (e.g., the 95th percentile) and add a modest buffer—say 10‑20 %—to the threshold. This way normal fluctuations stay below the limit, but a genuine upward drift will exceed it and produce a warning. Note that using manualChunks to isolate large modules can reduce warnings, but any change inside a shared manual chunk alters its hash and invalidates the browser cache for every entry point that imports it, potentially increasing request count and lowering cache efficiency.