Webpack Synchronizable Shell Plugin
raw JSON → 0.0.7 verified Sat Apr 25 auth: no javascript
A webpack plugin that runs shell commands before, after, or on exit of the build process, forked from webpack-shell-plugin. Version 0.0.7 (2018) is the latest stable release; no updates since. Unlike alternatives, it provides fine-grained control over script execution order with blocking and parallel options per lifecycle hook (onBuildStart, onBuildEnd, onBuildExit). Suitable for tasks like linting, testing, or deployment scripts. Note: development seems abandoned; last commit 2018.
Common errors
error TypeError: Cannot read property 'scripts' of undefined ↓
cause Passing scripts directly to plugin constructor instead of inside an object under onBuildStart/onBuildEnd/onBuildExit.
fix
Wrap scripts array inside an object, e.g., onBuildStart: { scripts: ['...'], blocking: false, parallel: false }
error Error: spawn ENOENT ↓
cause Shell command not found or safe:false default (uses spawn) fails on some systems.
fix
Set safe:true to use exec instead of spawn, or provide full path to command.
Warnings
gotcha Combining blocking:true with parallel:true is not supported; behavior undefined. ↓
fix Set at most one to true; if both needed, use sequential scripts or separate hooks.
breaking API differs from webpack-shell-plugin; direct scripts array is not accepted. ↓
fix Wrap scripts in onBuildStart/onBuildEnd/onBuildExit objects.
deprecated Option 'verbose' is deprecated and has no effect. ↓
fix Remove 'verbose' from configuration.
gotcha onBuildExit fires during watch mode after each compilation; not just on process exit. ↓
fix Use onBuildEnd for post-compilation tasks if you want to avoid repeated exit hooks.
Install
npm install webpack-synchronizable-shell-plugin yarn add webpack-synchronizable-shell-plugin pnpm add webpack-synchronizable-shell-plugin Imports
- WebpackSynchronizableShellPlugin wrong
import WebpackSynchronizableShellPlugin from 'webpack-synchronizable-shell-plugin';correctconst WebpackSynchronizableShellPlugin = require('webpack-synchronizable-shell-plugin'); - new WebpackSynchronizableShellPlugin({...}) wrong
new WebpackSynchronizableShellPlugin({ scripts: ['echo start'] })correctnew WebpackSynchronizableShellPlugin({ onBuildStart: { scripts: ['echo start'], blocking: true } }) - configuration structure wrong
onBuildStart: [] // directly passing arraycorrectonBuildStart: { scripts: [], blocking: false, parallel: false }
Quickstart
const WebpackSynchronizableShellPlugin = require('webpack-synchronizable-shell-plugin');
module.exports = {
entry: './src/index.js',
output: { path: __dirname + '/dist', filename: 'bundle.js' },
plugins: [
new WebpackSynchronizableShellPlugin({
onBuildStart: {
scripts: ['echo "Build starting..."'],
blocking: true,
parallel: false
},
onBuildEnd: {
scripts: ['echo "Build complete"'],
blocking: false,
parallel: true
},
onBuildExit: {
scripts: ['echo "Done"'],
blocking: false,
parallel: false
},
dev: true,
safe: false
})
]
};