A Webpack plugin (v0.4.0) that executes arbitrary shell scripts in response to Webpack compiler hooks. It integrates with the full range of Webpack compiler hooks (afterEmit, done, assetEmitted, etc.). Supports running single commands, multiple parallel commands, and dynamic command generation from hook arguments via functions. Uses instead of exec for robust process handling. Compatible with Webpack 4 and 5. Released under MIT; maintained by Drew Loomer. Key differentiator: simple, functional approach compared to alternatives like webpack-shell-plugin.
npm install hook-shell-script-webpack-pluginVerified import paths — ran on the pinned version, not inferred.
Shows minimal webpack config using plugin to run shell commands after emit and on done.
Use asynchronous hooks or shell backgrounding (&) to avoid blocking.
Check Webpack 5 compiler hooks reference and update plugin configuration accordingly.
Use process.env in shell command strings or pass variables via command arguments.
Consider using shell scripts that write to files or use async alternatives like webpack-shell-plugin-next.
If you used array returns for parallel commands, refactor to use object returns for each command.
Run npm install --save-dev hook-shell-script-webpack-plugin and ensure it's in node_modules.
Use const HookShellScriptPlugin = require('hook-shell-script-webpack-plugin');Consult webpack compiler hooks documentation and use the correct hook name for your webpack version.