Elegant ProgressBar and Profiler for Webpack and Rspack
npx @tessl/cli install tessl/npm-webpackbar@6.0.0WebpackBar is an elegant progress bar and profiler plugin for Webpack and Rspack build tools. It provides real-time build progress visualization with customizable progress bars, supports multiple concurrent builds (useful for SSR scenarios), includes advanced build profiling capabilities, and offers a fully customizable reporting system.
npm install webpackbar// Webpack usage
import WebpackBar from "webpackbar";// Rspack usage
import WebpackBar from "webpackbar/rspack";For CommonJS:
// Webpack usage
const WebpackBar = require("webpackbar");
// Rspack usage
const WebpackBar = require("webpackbar/rspack");Type imports:
import type { WebpackBarOptions, Reporter, State } from "webpackbar";
// or
import type { WebpackBarOptions, Reporter, State } from "webpackbar/rspack";// Webpack configuration
import WebpackBar from "webpackbar";
export default {
// ... your webpack config
plugins: [
new WebpackBar({
name: 'My App',
color: 'blue',
profile: true
})
]
};// Rspack configuration
import WebpackBar from "webpackbar/rspack";
export default {
// ... your rspack config
plugins: [
new WebpackBar({
name: 'My App',
color: 'blue',
profile: true
})
]
};WebpackBar is built around several key components:
webpackbar) and Rspack (webpackbar/rspack)WebpackBar class that manages state and reportersCore plugin classes for integrating with Webpack and Rspack build processes.
import type webpack from "webpack";
import type * as rspack from "@rspack/core";
// Webpack integration
export default class WebpackBarProgressPlugin extends webpack.ProgressPlugin {
webpackbar: WebpackBar;
constructor(options?: WebpackBarOptions);
apply(compiler: webpack.Compiler): void;
}
// Rspack integration
export default class WebpackBarProgressPlugin extends rspack.ProgressPlugin {
webpackbar: WebpackBar;
constructor(options?: WebpackBarOptions);
apply(compiler: rspack.Compiler): void;
}The main WebpackBar class that manages state and reporters.
import type webpack from "webpack";
export declare class WebpackBar {
// State properties
readonly hasRunning: boolean; // Whether any compilation is running
readonly hasErrors: boolean; // Whether any compilation has errors
readonly statesArray: State[]; // Array of all compilation states
readonly states: { [key: string]: State }; // Global states object
readonly state: State; // Current state for this plugin instance
constructor(options?: WebpackBarOptions);
apply(compiler: webpack.Compiler): void;
updateProgress(percent?: number, message?: string, details?: string[]): void;
}Comprehensive configuration system for customizing progress display and behavior.
interface WebpackBarOptions {
name?: string; // Display name (default: 'build')
color?: string; // Progress bar color (default: 'green')
profile?: boolean; // Enable profiler (default: false)
fancy?: boolean; // Enable bars reporter (default: true when not in CI)
basic?: boolean; // Enable simple log reporter (default: true in minimal envs)
reporter?: ReporterInput; // Single custom reporter
reporters?: ReporterInput[]; // Array of custom reporters
}Built-in reporters and custom reporter interfaces for displaying build progress in different formats.
import type webpack from "webpack";
interface Reporter {
start?(context: WebpackBar): void;
change?(context: WebpackBar, payload: { path: string; shortPath: string; time: number }): void;
update?(context: WebpackBar): void;
done?(context: WebpackBar, payload: { stats: webpack.Stats }): void;
progress?(context: WebpackBar): void;
allDone?(context: WebpackBar): void;
beforeAllDone?(context: WebpackBar): void;
afterAllDone?(context: WebpackBar): void;
}
// WebpackBar class that serves as the context for reporters
declare class WebpackBar {
readonly hasRunning: boolean; // Whether any compilation is running
readonly hasErrors: boolean; // Whether any compilation has errors
readonly statesArray: State[]; // Array of all compilation states
readonly states: { [key: string]: State }; // Global states object
readonly state: State; // Current state for this plugin instance
constructor(options?: WebpackBarOptions);
apply(compiler: webpack.Compiler): void;
updateProgress(percent?: number, message?: string, details?: string[]): void;
}Built-in profiling system for analyzing build performance and identifying bottlenecks.
interface State {
start: [number, number] | null; // High-resolution start time
progress: number; // Progress percentage (-1 to 100)
done: boolean; // Compilation completion status
message: string; // Current status message
details: string[]; // Additional status details
request: null | { // Current processing request
file: null | string;
loaders: string[];
};
hasErrors: boolean; // Error status
color: string; // Associated color
name: string; // Display name
}type ReporterOpts = { reporter: Reporter | string; options?: any };
type ReporterInput = string | [Reporter | string, any?] | ReporterOpts;
// Re-exported from main entry points
export { WebpackBarOptions, Reporter, State } from "webpackbar";
export { WebpackBarOptions, Reporter, State } from "webpackbar/rspack";