{"id":20828,"library":"webpack-shell-plugin","title":"Webpack Shell Plugin","description":"A webpack plugin that executes shell commands before and after webpack builds. Version 0.5.0 requires webpack 4+ (peer dependency). It supports arrays of commands for start, end, and exit phases, and provides a 'dev' mode to avoid re-running scripts in watch/watch-dev-server. Unlike alternatives like shelljs-webpack-plugin, it uses spawn by default but offers a 'safe' flag to fall back to exec. The plugin is unmaintained since 2019 and may have issues with webpack 5.","status":"maintenance","version":"0.5.0","language":"javascript","source_language":"en","source_url":"https://github.com/1337programming/webpack-shell-plugin","tags":["javascript","webpack","shell","plugin","serve","hmr","browser","script"],"install":[{"cmd":"npm install webpack-shell-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add webpack-shell-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add webpack-shell-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency - plugin hooks into webpack compilation lifecycle","package":"webpack","optional":false}],"imports":[{"note":"Package does not ship ESM; use CommonJS require. For TypeScript, you may need to install @types/webpack-shell-plugin or use require with no types.","wrong":"import WebpackShellPlugin from 'webpack-shell-plugin';","symbol":"WebpackShellPlugin","correct":"const WebpackShellPlugin = require('webpack-shell-plugin');"}],"quickstart":{"code":"const WebpackShellPlugin = require('webpack-shell-plugin');\nconst path = require('path');\n\nmodule.exports = {\n  entry: path.resolve(__dirname, 'src/app.js'),\n  output: {\n    path: path.resolve(__dirname, 'dist'),\n    filename: 'bundle.js'\n  },\n  plugins: [\n    new WebpackShellPlugin({\n      onBuildStart: ['echo \"Build started\"'],\n      onBuildEnd: ['echo \"Build ended\"'],\n      onBuildExit: ['echo \"Webpack process complete\"'],\n      dev: false\n    })\n  ]\n};","lang":"javascript","description":"Shows how to use WebpackShellPlugin with all three hooks (start, end, exit) in a webpack config."},"warnings":[{"fix":"Remove the verbose option from the plugin configuration.","message":"The 'verbose' option is deprecated and has no effect.","severity":"deprecated","affected_versions":">=0.3.0"},{"fix":"Add { safe: true } to options.","message":"On Windows, spawn may fail due to shell differences. Use the 'safe' option to switch to exec which uses cmd.","severity":"gotcha","affected_versions":">=0.5.0"},{"fix":"Wrap scripts in try-catch or redirect stderr to a log.","message":"The plugin does not expose a return value for scripts; any errors may not be caught.","severity":"gotcha","affected_versions":">=0.5.0"},{"fix":"Use a fork like 'webpack-shell-plugin-next' or upgrade to a maintained plugin.","message":"Plugin may not work with webpack 5 without modification due to removed legacy plugin API.","severity":"breaking","affected_versions":">=0.5.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'npm install --save-dev webpack-shell-plugin' and use require('webpack-shell-plugin') in webpack.config.js.","cause":"Module not installed or incorrect import path.","error":"Error: Cannot find module 'webpack-shell-plugin'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}