vite-size
raw JSON → 0.0.6 verified Fri May 01 auth: no javascript
vite-size is a lightweight CLI tool that measures the bundle size of any Vite build output. It provides quick feedback on bundle size directly from the terminal without needing additional reporting tools. The current stable version is 0.0.6, released as an early-stage package with no fixed release cadence. Key differentiators include simple setup via npm scripts, support for external packages via --externals flag, and a --lib mode for library projects without an index.html. It ships TypeScript types and works with any Vite project.
Common errors
error command not found: vite-size ↓
cause Package not installed globally or locally
fix
Install as dev dependency: pnpm i -D vite-size or run via npx: npx vite-size
error No index.html found. Use --lib for library mode. ↓
cause Project has no index.html (e.g., library project) and --lib flag not set
fix
Add --lib flag: vite-size --lib
Warnings
gotcha --externals must be the last flag in the script; otherwise it may not parse correctly ↓
fix Always put --externals at the end of the command line arguments.
gotcha Requires a TypeScript compilation step (npx tsc) before running; otherwise may report on stale output ↓
fix Run npx tsc first or ensure your build is up-to-date.
deprecated CLI only, no programmatic API available ↓
fix Use CLI via npx or scripts; do not attempt to import from Node.js.
Install
npm install vite-size yarn add vite-size pnpm add vite-size Imports
- default (CLI) wrong
import viteSize from 'vite-size'correctnpx vite-size - None (type exports) wrong
import { ViteSizeOptions } from 'vite-size'correct// No import needed for types; types are bundled for CLI only
Quickstart
// package.json
{
"scripts": {
"size": "npx tsc && vite-size"
}
}
// Then run:
npm run size
// With externals:
// "size": "npx tsc && vite-size --externals react react-dom"
// For lib mode (no index.html):
// "size": "npx tsc && vite-size --lib --externals react"