The `on-build-webpack` package provides a Webpack plugin designed to execute a callback function immediately after a build completes. Published as version `0.1.0` in October 2014, this package is considered abandoned and is not actively maintained. Its functionality is extremely basic, offering a single post-build hook, which contrasts sharply with the extensive `compiler.hooks` API introduced in modern Webpack versions (v4+). This plugin uses an outdated Webpack API (`compiler.plugin('done', ...)`) that has been replaced by the Tapable hook system (`compiler.hooks.done.tap(...)`). Consequently, it is incompatible with Webpack v4 and newer. Current best practice is to use Webpack's native plugin system directly via `compiler.hooks.done.tap` within a custom plugin.
npm install on-build-webpackVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to integrate the `WebpackOnBuildPlugin` into a `webpack.config.js` file to execute a callback after a successful or failed build. It shows basic setup for a project with `src/index.js` as the entry point, bundling to `dist/bundle.js`. Note: This plugin is outdated and likely incompatible with modern Webpack versions (v4 and above).
Do not use `on-build-webpack` with modern Webpack. Instead, implement a custom plugin using `compiler.hooks.done.tap` within your `webpack.config.js` or a separate plugin file. For example:
```javascript
class MyModernBuildPlugin {
apply(compiler) {
compiler.hooks.done.tap('MyModernBuildPlugin', (stats) => {
if (stats.hasErrors()) {
console.error('Modern Webpack build failed!');
} else {
console.log('Modern Webpack build completed!');
}
});
}
}
// In webpack.config.js:
// plugins: [new MyModernBuildPlugin()]
```Migrate to using Webpack's built-in `compiler.hooks.done.tap` API for post-build actions or consider a well-maintained alternative if more complex functionality is required.
If you absolutely must use this plugin (e.g., in a legacy project with old Webpack), ensure your `webpack.config.js` uses CommonJS `require` syntax. For new projects, use modern Webpack APIs.
Upgrade your custom plugin to use `compiler.hooks.done.tap` (or other relevant hooks) instead of the deprecated `compiler.plugin` method. Refer to Webpack's official documentation on Compiler Hooks.
Ensure that your `webpack.config.js` is a CommonJS module (`.js` or `.cjs` with `type: "commonjs"` in `package.json`) if you intend to `require` this package. For modern Webpack, prefer creating a new plugin using ESM and Webpack's `compiler.hooks` API.
Given the package's age and abandoned status, it's strongly recommended to replace it with a modern, custom plugin utilizing `compiler.hooks.done.tap` for reliable post-build execution.
No dependency data recorded yet.