Registry / devops / hook-shell-script-webpack-plugin

hook-shell-script-webpack-plugin

JSON →
library0.4.0jsnpmunverified

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-plugin
INSTALL
IMPORT
SIG · HOOK-SHELL-SCRIPT-
H
hook-shell-script-webpack-plugin
devopsjavascriptv0.4.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

HookShellScriptPlugin
const HookShellScriptPlugin = require('hook-shell-script-webpack-plugin');
import HookShellScriptPlugin from 'hook-shell-script-webpack-plugin';
The package exports via module.exports = class; CommonJS require is correct. ESM import may fail due to lack of named exports.
default
const HookShellScriptPlugin = require('hook-shell-script-webpack-plugin');
const { HookShellScriptPlugin } = require('hook-shell-script-webpack-plugin');
The class is the default export; destructuring will result in undefined.
type definitions
No TypeScript types shipped. Use @types/hook-shell-script-webpack-plugin if available.
Package has no TypeScript declarations. Consider declaring module manually or using any.

Shows minimal webpack config using plugin to run shell commands after emit and on done.

// webpack.config.js const path = require('path'); const webpack = require('webpack'); const HookShellScriptPlugin = require('hook-shell-script-webpack-plugin'); module.exports = { entry: './src/index.js', output: { path: path.resolve(__dirname, 'dist'), filename: 'bundle.js' }, plugins: [ new HookShellScriptPlugin({ afterEmit: ['echo "Build complete!"'], done: ['echo "Done!"'] }) ] };
Debug
Known issues
gotchaCommands run synchronously and block the webpack build until completion.
fix
Use asynchronous hooks or shell backgrounding (&) to avoid blocking.
affects: >=0.1.0
deprecatedHook names like 'afterEmit' are deprecated in Webpack 5; use 'emit' instead.
fix
Check Webpack 5 compiler hooks reference and update plugin configuration accordingly.
affects: >=0.3.0
gotchaEnvironment variables from the build are not automatically passed to shell scripts.
fix
Use process.env in shell command strings or pass variables via command arguments.
affects: >=0.1.0
gotchaThe plugin uses child_process.execSync, which may cause issues with large output or long-running scripts.
fix
Consider using shell scripts that write to files or use async alternatives like webpack-shell-plugin-next.
affects: >=0.1.0
breakingFrom v0.4.0, hook functions must return either a string or an object with command and args; returning an array is no longer supported.
fix
If you used array returns for parallel commands, refactor to use object returns for each command.
affects: >=0.4.0
Errors
Common errors & fixes
Module not found: Error: Can't resolve 'hook-shell-script-webpack-plugin'
Plugin not installed or webpack resolve fails.
fix
Run npm install --save-dev hook-shell-script-webpack-plugin and ensure it's in node_modules.
TypeError: HookShellScriptPlugin is not a constructor
Using an ES module import statement incorrectly; plugin is a CommonJS default export.
fix
Use const HookShellScriptPlugin = require('hook-shell-script-webpack-plugin');
Error: Hook 'afterEmit' is not supported
Webpack 5 deprecated some hooks; you're using a hook name that no longer exists.
fix
Consult webpack compiler hooks documentation and use the correct hook name for your webpack version.
Upgrade
Version history
0.4.0latest on npm
Audit
Dependencies
webpackrequiredpeer dependency; plugin hooks into webpack compiler lifecycle
Agent activity
4 hits · last 30 days
node
4
Resources
hook-shell-script-webpack-plugin — npm install hook-shell-script-webpack-plugin · libregistry