vite-plugin-bundlesize
Version:
Monitor bundle sizes and analyze bundle contents
50 lines (49 loc) • 1.32 kB
TypeScript
import { URL } from "node:url";
import type { Plugin } from "vite";
export interface Limit {
/**
* Filename or picomatch glob
* @example "**\/*.js"
*/
name: string;
/**
* Size limit
* @example "150 kB"
*/
limit: string | number;
/**
* Report sizes in "uncompressed", "gzip", or "brotli"
* @default "uncompressed"
*/
mode?: "uncompressed" | "gzip" | "brotli";
}
export interface Options {
/**
* Array of limit matches. Accepts globs via picomatch.
* The first match will apply, so the order of the array matters.
* @default [{ name: '**\/*', limit: '150 kB' }]
*/
limits?: Limit[];
/**
* Allow `vite build` to succeed even if bundlesize check fails
* @default false
*/
allowFail?: boolean;
/**
* Stat report verbosity. "summary" shows only failed stats; "all" shows everything.
* @default "summary"
*/
stats?: "summary" | "all";
/**
* Name of size report
* @default "bundlemeta.json"
*/
outputFile?: string;
}
export interface ResolvedConfig {
outputFile: URL;
limits: Limit[];
allowFail: NonNullable<Options["allowFail"]>;
stats: NonNullable<Options["stats"]>;
}
export default function vitePluginBundlesize(options?: Options): Plugin;