Webpack Compiler Plugin
raw JSON → 1.1.5 verified Fri May 01 auth: no javascript maintenance
Webpack Compiler Plugin (v1.1.5) lets you execute custom commands at key webpack compiler hook stages: buildStart, compileStart, compileEnd, and buildEnd. It wraps commands asynchronously and supports disabling stage messages. Last updated November 2020 with maintenance-only commits; no releases since. Differentiator: simple declarative API for hooking into webpack lifecycle without manual plugin wiring. Requires Node >=8, npm >=6, and webpack (peer dependency). Ships TypeScript type definitions.
Common errors
error Error: Cannot find module 'webpack-compiler-plugin' ↓
cause Package not installed or missing from dependencies.
fix
Run
npm install webpack-compiler-plugin --save-dev and ensure it's in package.json. error TypeError: WebpackCompilerPlugin is not a constructor ↓
cause Wrong import style – using default import instead of named import.
fix
Change to
import { WebpackCompilerPlugin } from 'webpack-compiler-plugin'. error Error: Cannot find module 'webpack' ↓
cause webpack peer dependency not installed.
fix
Run
npm install webpack --save-dev. Warnings
gotcha Listener functions must return a Promise or be synchronous; async functions are wrapped but not all callbacks are awaited. ↓
fix Update to v1.1.4+ where async functions are properly wrapped and return a promise.
deprecated The `stageMessages` option defaults to `true` but can be set to `null` to disable; in future versions this may change. ↓
fix Explicitly set `stageMessages: false` to disable stage messages.
gotcha Requires webpack as a peer dependency; installing without webpack will cause runtime errors. ↓
fix Install webpack: `npm install --save-dev webpack`.
gotcha The plugin only runs in Node.js environments; not usable in browser-based bundler integrations. ↓
fix Use exclusively in Node.js webpack configurations.
Install
npm install webpack-compiler-plugin yarn add webpack-compiler-plugin pnpm add webpack-compiler-plugin Imports
- WebpackCompilerPlugin wrong
const WebpackCompilerPlugin = require('webpack-compiler-plugin')correctimport { WebpackCompilerPlugin } from 'webpack-compiler-plugin' - WebpackCompilerPluginOptions wrong
import { WebpackCompilerPluginOptions } from 'webpack-compiler-plugin'correctimport type { WebpackCompilerPluginOptions } from 'webpack-compiler-plugin' - Stages
import { Stages } from 'webpack-compiler-plugin'
Quickstart
// webpack.config.js
import { WebpackCompilerPlugin } from 'webpack-compiler-plugin';
export default {
mode: 'development',
plugins: [
new WebpackCompilerPlugin({
name: 'my-plugin',
listeners: {
buildStart: () => console.log('Build started'),
compileEnd: () => console.log('Compilation ended'),
},
stageMessages: false, // disable stage messages
}),
],
};