@pixpilot/rollup-plugin-size-limit
v0.1.3
Published
Enforce bundle size limits in Rollup, Vite, and tsdown builds with configurable thresholds and CI/CD integration
Readme
@pixpilot/rollup-plugin-size-limit
A Rollup plugin that enforces bundle size limits during the build process. It checks the size of output files against configurable thresholds and can either warn or throw errors when limits are exceeded.
Features
- ✅ Enforce maximum bundle sizes
- ✅ Support for chunks and assets
- ✅ Configurable error vs warning behavior
- ✅ Automatic size formatting
- ✅ Compatible with Rollup, Vite, and tsdown
- ✅ Skips source maps and type declarations
Installation
pnpm add -D @pixpilot/rollup-plugin-size-limitUsage
Basic Usage
import { sizeLimit } from '@pixpilot/rollup-plugin-size-limit';
export default {
// ... other config
plugins: [
sizeLimit(1024 * 1024), // 1MB limit
],
};Advanced Configuration
import { sizeLimit } from '@pixpilot/rollup-plugin-size-limit';
export default {
// ... other config
plugins: [
sizeLimit({
maxSize: 500 * 1024, // 500KB
throwError: false, // Warn instead of throwing error
}),
],
};Options
maxSize(number): Maximum allowed size in bytesthrowError(boolean, optional): Whether to throw an error (default:true) or just warn
Option Formats
number: SetsmaxSizein bytes,throwErrordefaults totrueobject: Full configuration withmaxSizeand optionalthrowErrorboolean:falsedisables the plugin,truerequiresmaxSizeto be set elsewhere
Example Output
✓ index.js: 245.8 kB / 500 kB
⚠️ vendor.js: 1.2 MB (max: 1 MB)