{"id":20827,"library":"webpack-shell-plugin-next","title":"webpack-shell-plugin-next","description":"Run shell commands before, during, and after webpack 5 builds. Current stable version 2.3.3, with regular updates. Supports TypeScript types and provides fine-grained lifecycle hooks (onBuildStart, onBuildEnd, onBuildExit, onWatchRun, etc.) with blocking and parallel execution control. Differentiator: actively maintained fork of the original webpack-shell-plugin, compatible only with webpack 5 (v2.x) and offering more hooks and TypeScript support.","status":"active","version":"2.3.3","language":"javascript","source_language":"en","source_url":"https://github.com/s00d/webpack-shell-plugin-next","tags":["javascript","webpack","shell","plugin","serve","hmr","browser","script","typescript"],"install":[{"cmd":"npm install webpack-shell-plugin-next","lang":"bash","label":"npm"},{"cmd":"yarn add webpack-shell-plugin-next","lang":"bash","label":"yarn"},{"cmd":"pnpm add webpack-shell-plugin-next","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency; plugin uses webpack's compiler hooks API","package":"webpack","optional":false}],"imports":[{"note":"This package is CommonJS-only (no ESM export). In TypeScript, use the require syntax or set 'esModuleInterop' to true if using import.","wrong":"import WebpackShellPluginNext from 'webpack-shell-plugin-next';","symbol":"WebpackShellPluginNext","correct":"const WebpackShellPluginNext = require('webpack-shell-plugin-next');"},{"note":"TypeScript users should use import x = require() for CommonJS modules; named import is not available.","wrong":"import { WebpackShellPluginNext } from 'webpack-shell-plugin-next';","symbol":"WebpackShellPluginNext","correct":"import WebpackShellPluginNext = require('webpack-shell-plugin-next');"},{"note":"Since v2, lifecycle hooks expect a configuration object with 'scripts' array, not an array of strings directly.","wrong":"new WebpackShellPluginNext({ onBuildStart: ['echo start'] })","symbol":"Plugin configuration object","correct":"new WebpackShellPluginNext({ onBuildStart: { scripts: ['echo start'], blocking: true } })"}],"quickstart":{"code":"const WebpackShellPluginNext = require('webpack-shell-plugin-next');\n\nmodule.exports = {\n  plugins: [\n    new WebpackShellPluginNext({\n      onBuildStart: {\n        scripts: ['echo \"Build starting...\"'],\n        blocking: true,\n        parallel: false\n      },\n      onBuildEnd: {\n        scripts: ['echo \"Build completed!\"'],\n        blocking: false,\n        parallel: true\n      },\n      onBuildExit: {\n        scripts: ['echo \"Exiting webpack\"']\n      },\n      onWatchRun: {\n        scripts: ['echo \"Watch mode triggered\"'],\n        blocking: false\n      },\n      env: { NODE_ENV: 'production' },\n      logging: true,\n      swallowError: false\n    })\n  ]\n};","lang":"javascript","description":"Configures the plugin with multiple lifecycle hooks, blocking/parallel options, environment variables, and logging control."},"warnings":[{"fix":"Upgrade to webpack 5 or use v1.x (webpack-shell-plugin-next@1) for webpack 4.","message":"v2.0.0 dropped webpack 4 support. Only webpack 5 is supported.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Change from `onBuildStart: ['echo start']` to `onBuildStart: { scripts: ['echo start'] }`.","message":"v2.0.0 changed configuration structure: lifecycle hooks now expect an object (with scripts array) instead of a flat array.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Replace `onBeforeBuild` with `onBuildStart`, `onBuildError` with `onFailedBuild`.","message":"The `onBeforeBuild` and `onBuildError` hooks are deprecated in v2. Use `onBuildStart` and `onFailedBuild` instead.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Set only one of them to true, or both to false.","message":"Using both `blocking: true` and `parallel: true` together throws an error: they are mutually exclusive.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use `onBeforeNormalRun` or `onDoneWatch` for more precise control.","message":"The `onBuildExit` hook also fires in watch mode when webpack finishes updating the bundle, not just on exit.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Replace `import WebpackShellPluginNext from 'webpack-shell-plugin-next'` with `const WebpackShellPluginNext = require('webpack-shell-plugin-next')`.","cause":"ESM import used incorrectly; package is CommonJS.","error":"TypeError: WebpackShellPluginNext is not a constructor"},{"fix":"Run `npm install --save-dev webpack-shell-plugin-next` and ensure webpack 5 is installed.","cause":"Missing npm install or wrong peer dependency webpack version.","error":"Cannot find module 'webpack-shell-plugin-next'"},{"fix":"Ensure each lifecycle hook's scripts property is an array, e.g., `onBuildStart: { scripts: ['command'] }`.","cause":"Configuration for a lifecycle hook was passed as a string or invalid type.","error":"Error: the scripts option should be an array of strings"},{"fix":"Set at most one of them to true, or leave both false (defaults to serial non-blocking).","cause":"Both blocking and parallel options set to true in a lifecycle config.","error":"Error: blocking and parallel cannot both be true"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}