{"id":14784,"library":"on-build-webpack","title":"Webpack OnBuild Plugin","description":"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.","status":"abandoned","version":"0.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/kossnocorp/on-build-webpack","tags":["javascript","webpack"],"install":[{"cmd":"npm install on-build-webpack","lang":"bash","label":"npm"},{"cmd":"yarn add on-build-webpack","lang":"bash","label":"yarn"},{"cmd":"pnpm add on-build-webpack","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS-only and does not support ESM imports. It is designed for very old Webpack versions.","wrong":"import WebpackOnBuildPlugin from 'on-build-webpack';\n// OR\nimport { WebpackOnBuildPlugin } from 'on-build-webpack';","symbol":"WebpackOnBuildPlugin","correct":"const WebpackOnBuildPlugin = require('on-build-webpack');"}],"quickstart":{"code":"const path = require('path');\nconst WebpackOnBuildPlugin = require('on-build-webpack');\n\nmodule.exports = {\n  mode: 'development',\n  entry: './src/index.js',\n  output: {\n    filename: 'bundle.js',\n    path: path.resolve(__dirname, 'dist'),\n  },\n  plugins: [\n    new WebpackOnBuildPlugin(function(stats) {\n      // The 'stats' object contains information about the build.\n      // For modern Webpack, 'stats.hasErrors()' and 'stats.hasWarnings()' are useful.\n      // For this old plugin, the structure of 'stats' might differ.\n      if (stats.hasErrors()) {\n        console.error('Webpack build failed with errors!');\n        console.error(stats.toString({ colors: true }));\n      } else {\n        console.log('Webpack build completed successfully!');\n      }\n    }),\n  ],\n  // Note: This configuration is for demonstration of the plugin's original usage.\n  // It is unlikely to work with modern Webpack (v4+).\n  // For modern Webpack, directly use compiler.hooks.done.tap.\n};\n","lang":"javascript","description":"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)."},"warnings":[{"fix":"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:\n\n```javascript\nclass MyModernBuildPlugin {\n  apply(compiler) {\n    compiler.hooks.done.tap('MyModernBuildPlugin', (stats) => {\n      if (stats.hasErrors()) {\n        console.error('Modern Webpack build failed!');\n      } else {\n        console.log('Modern Webpack build completed!');\n      }\n    });\n  }\n}\n// In webpack.config.js:\n// plugins: [new MyModernBuildPlugin()]\n```","message":"This plugin is incompatible with Webpack v4, v5, and later versions. It uses an older plugin API (`compiler.plugin`) which has been removed in favor of the new Tapable hook system (`compiler.hooks`).","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"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.","message":"The `on-build-webpack` package is abandoned. It was last published in 2014 as version 0.1.0 and has seen no maintenance since. This means it will not receive updates for Webpack compatibility, bug fixes, or security patches.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"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.","message":"This plugin is CommonJS-only and cannot be imported using ES module syntax (`import`). Attempting to do so in a modern Webpack configuration that expects ESM will result in errors.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"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.","cause":"Using `on-build-webpack` with Webpack v4 or higher. The `compiler.plugin` method was removed and replaced by `compiler.hooks` in Webpack's new Tapable API.","error":"TypeError: compiler.plugin is not a function"},{"fix":"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.","cause":"Attempting to `require` this CommonJS-only package in an ES module context, or vice-versa, when Node.js is configured for strict ESM.","error":"ERR_REQUIRE_ESM"},{"fix":"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.","cause":"The plugin is so old that its internal workings might be fundamentally incompatible with even slightly newer versions of Webpack, leading to silent failures or unexpected behavior in the plugin lifecycle.","error":"Webpack build fails without an explicit error message related to on-build-webpack, or the callback function is never executed."}],"ecosystem":"npm"}