
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
vite-bundle-analyzer
Advanced tools
A bundle analyzer for Vite, Rollup, and Rolldown that visualizes bundle size with an interactive treemap.
[!WARNING] Vite enables minification by default. The parsed size may appear larger than actual size because bundle info from Rollup isn't compressed. Rolldown support is experimental.
npm install vite-bundle-analyzer -D
# or
yarn add vite-bundle-analyzer -D
# or
pnpm add vite-bundle-analyzer -D
import { defineConfig } from 'vite'
import { analyzer } from 'vite-bundle-analyzer'
export default defineConfig({
plugins: [
analyzer()
]
})
import { adapter } from 'vite-bundle-analyzer'
import { analyzer } from 'vite-bundle-analyzer'
export default {
plugins: [
adapter(analyzer())
]
}
import { unstableRolldownAdapter } from 'vite-bundle-analyzer'
import { analyzer } from 'vite-bundle-analyzer'
export default {
plugins: [
unstableRolldownAdapter(analyzer())
]
}
| Option | Type | Default | Description |
|---|---|---|---|
analyzerMode | 'server' | 'static' | 'json' | function | 'server' | Analysis output mode |
fileName | string | function | 'stats' | Output filename (without extension) |
reportTitle | string | 'Vite Bundle Analyzer' | Report page title |
gzipOptions | Record<string, any> | {} | Gzip compression options (see zlib module) |
brotliOptions | Record<string, any> | {} | Brotli compression options |
analyzerPort | number | 'auto' | 8888 | Server port |
openAnalyzer | boolean | true | Auto-open browser (server/static mode only) |
defaultSizes | 'stat' | 'gzip' | 'brotli' | 'stat' | Default size metric |
summary | boolean | true | Show summary in console |
enabled | boolean | true | Enable/disable plugin |
include | string | RegExp | Array<string | RegExp> | [] | Include patterns |
exclude | string | RegExp | Array<string | RegExp> | [] | Exclude patterns |
pathFormatter | (path: string, defaultWd: string) => string | undefined | Formatting Paths |
npx vite-bundle-analyzer
# With options
npx vite-bundle-analyzer --help
If chunk sizes appear empty, check for plugins that break source maps (e.g., @vitejs/plugin-legacy). The analyzer relies on source maps for accurate size calculation.
For frameworks built on Vite (VitePress, Remix, Qwik), use analyzerMode: 'server' for accurate results due to multiple build instances.
When analyzerMode: 'static' and openAnalyzer: false, no development server is created.
import { SSE, createServer, injectHTMLTag, openBrowser, renderView } from 'vite-bundle-analyzer'
// Create custom server
const server = createServer()
server.get('/', async (c) => {
const html = await renderView(data, { title: 'Custom Analyzer', mode: 'stat' })
c.res.writeHead(200, { 'Content-Type': 'text/html' })
c.res.write(html)
c.res.end()
})
server.listen(3000)
# Vite
vite build --debug
# Environment variable
ANALYZE_DEBUG=true npm run build
webpack-bundle-analyzer is a popular tool for visualizing the size of webpack output files with an interactive zoomable treemap. It is similar to vite-bundle-analyzer but specifically designed for use with webpack, offering a wide range of customization options and detailed insights into bundle composition.
rollup-plugin-visualizer is a plugin for Rollup that provides a similar bundle analysis and visualization functionality. It generates an interactive treemap visualization of the bundle, helping developers optimize their Rollup builds. It is comparable to vite-bundle-analyzer but tailored for Rollup users.
FAQs
a modern vite bundle analyzer tool
The npm package vite-bundle-analyzer receives a total of 165,998 weekly downloads. As such, vite-bundle-analyzer popularity was classified as popular.
We found that vite-bundle-analyzer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.