done-webpack-plugin
raw JSON → 1.0.3 verified Fri May 01 auth: no javascript
A webpack plugin that registers a callback to be executed when the compiler's 'done' hook is triggered, providing access to compilation stats. Version 1.0.3 is the current stable release. It offers a simple API with optional error callback, distinct from webpack's built-in hooks or other plugin-based approaches.
Common errors
error TypeError: DoneWebpackPlugin is not a constructor ↓
cause ESM import instead of require.
fix
Use
const DoneWebpackPlugin = require('done-webpack-plugin'); instead of import. error Error: Cannot find module 'webpack' ↓
cause Missing webpack as a peer dependency.
fix
Run
npm install --save-dev webpack or ensure webpack is installed. Warnings
breaking Requires webpack 4 or later; uses webpack 4's hooks API. ↓
fix Upgrade to webpack 4+.
deprecated Package is not actively maintained; last update was in 2018. ↓
fix Consider using webpack's built-in 'done' hook or a more modern alternative.
gotcha Error callback is not called for compiler errors; only for plugin internal errors. ↓
fix Use webpack's 'error' stats or handle errors in the success callback via stats.hasErrors().
Install
npm install done-webpack-plugin yarn add done-webpack-plugin pnpm add done-webpack-plugin Imports
- DoneWebpackPlugin (default) wrong
import { DoneWebpackPlugin } from 'done-webpack-plugin';correctconst DoneWebpackPlugin = require('done-webpack-plugin'); - new DoneWebpackPlugin(callback) wrong
new DoneWebpackPlugin().onDone(stats => { ... })correctnew DoneWebpackPlugin((stats) => { ... }) - Error callback wrong
new DoneWebpackPlugin(errorCb, successCb)correctnew DoneWebpackPlugin(successCb, errorCb)
Quickstart
// webpack.config.js
const DoneWebpackPlugin = require('done-webpack-plugin');
module.exports = {
plugins: [
new DoneWebpackPlugin(
(stats) => {
console.log('Build finished in', stats.endTime - stats.startTime, 'ms');
},
(err) => {
console.error('Build error:', err);
}
)
]
};