vite-bundle-analyzer

a modern vite bundle analyzer tool

MIT 81 个版本
安装
npm install vite-bundle-analyzer
yarn add vite-bundle-analyzer
pnpm add vite-bundle-analyzer
bun add vite-bundle-analyzer
README

vite-bundle-analyzer

Awesome

Vite Bundle Analyzer

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.

Installation

npm install vite-bundle-analyzer -D
# or
yarn add vite-bundle-analyzer -D
# or
pnpm add vite-bundle-analyzer -D

Usage

Plugins only work during the build phase.

Vite

import { defineConfig } from 'vite'
import { analyzer } from 'vite-bundle-analyzer'

export default defineConfig({
  plugins: [
    analyzer()
  ]
})

Rollup

import { adapter } from 'vite-bundle-analyzer'
import { analyzer } from 'vite-bundle-analyzer'

export default {
  plugins: [
    adapter(analyzer())
  ]
}

Rolldown Plugin (Experimental)

import { unstableRolldownAdapter } from 'vite-bundle-analyzer'
import { analyzer } from 'vite-bundle-analyzer'

export default {
  plugins: [
    unstableRolldownAdapter(analyzer())
  ]
}

Configuration

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

CLI

npx vite-bundle-analyzer

# With options
npx vite-bundle-analyzer --help

# If you're using rolldown-vite pls using the following command

npx vite-bundle-analyzer -e=rolldown-vite

Common Issues

Empty Chunk Sizes

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.

Vite-based Frameworks

For frameworks built on Vite (VitePress, Remix, Qwik), use analyzerMode: 'server' for accurate results due to multiple build instances.

Static Mode Without Server

When analyzerMode: 'static' and openAnalyzer: false, no development server is created.

API Integration

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)

Debug

# Vite
vite build --debug

# Environment variable
ANALYZE_DEBUG=true npm run build

Contributors

Kanno Aleksandr Mitskevich mengdaoshizhongxinyang

Sponsors

Credits

  • Geist UI
  • The friend who proposed this idea.
  • All contributors and sponsors

License

MIT

版本列表
1.3.9 2026-07-13
1.3.8 2026-04-27
1.3.7 2026-04-06
1.3.6 2026-02-04
1.3.5 2026-02-03
1.3.4 2026-02-02
1.3.3 2026-02-02
1.3.2 2025-12-14
1.3.1 2025-12-08
1.3.0 2025-12-07
1.2.4 2025-12-05
1.2.3 2025-08-29
1.2.2 2025-08-28
1.2.1 2025-08-09
1.2.0 2025-08-06
1.1.2 2025-08-06
1.1.1 2025-08-06
1.1.0 2025-07-10
1.0.0 2025-06-30
0.23.0 2025-06-24
0.22.3 2025-06-13
0.22.2 2025-06-09
0.22.1 2025-06-09
0.22.0 2025-05-27
0.21.0 2025-05-19
0.20.2 2025-05-13
0.20.1 2025-04-29
0.20.0 2025-04-29
0.19.0 2025-04-18
0.18.1 2025-03-21
0.18.0 2025-03-15
0.17.3 2025-03-13
0.17.2 2025-03-13
0.17.1 2025-02-18
0.17.0 2025-02-07
0.16.3 2025-02-06
0.16.2 2025-02-03
0.16.1 2025-01-28
0.16.0-beta.4 2024-12-29
0.16.0-beta.3 2024-12-17
0.16.0-beta.2 2024-12-17
0.16.0-beta.1 2024-12-03
0.16.0 2025-01-07
0.15.2 2024-11-29
0.15.1 2024-11-28
0.15.0 2024-11-28
0.14.3 2024-11-26
0.14.2 2024-11-25
0.14.1 2024-11-24
0.14.0 2024-11-24
0.13.1 2024-11-13
0.13.0 2024-11-08
0.12.1 2024-09-27
0.12.0 2024-09-26
0.11.1 2024-09-19
0.11.0 2024-09-16
0.10.6 2024-08-22
0.10.5 2024-08-08
0.10.4 2024-08-07
0.10.3 2024-06-18
0.10.2 2024-06-13
0.10.1 2024-06-13
0.10.0 2024-06-12
0.9.4 2024-04-12
0.9.3 2024-04-08
0.9.2 2024-03-20
0.9.1 2024-03-19
0.9.0 2024-03-16
0.8.3 2024-03-10
0.8.2 2024-03-09
0.8.1 2024-02-26
0.8.0 2024-02-19
0.7.0 2024-01-17
0.6.1 2024-01-03
0.6.0 2024-01-02
0.5.0 2023-12-08
0.4.0 2023-11-21
0.3.0 2023-11-16
0.2.0 2023-11-15
0.1.0 2023-10-25
0.0.1 2023-10-17