This plugin is a fork of webpack-shell-plugin.
It differs from webpack-shell-plugin by allowing user to customize script execution order. For example, we can specify that webpack should block until user's precompile scripts finish executing. Another example is we can execute scripts in the order in which they are specified, or we can execute them in parallel.
The point of this plugin is to give users freedom in choosing how scripts are executed.
npm install --save-dev webpack-synchronizable-shell-plugin
In webpack.config.js
:
const WebpackSynchronizableShellPlugin = require('webpack-synchronizable-shell-plugin');
module.exports = {
...
...
plugins: [
new WebpackSynchronizableShellPlugin({
onBuildStart:{
scripts: ['echo "Webpack Start"'],
blocking: true,
parallel: false
},
onBuildEnd:{
scripts: ['echo "Webpack End"'],
blocking: false,
parallel: true
}
})],
...
}
onBuildStart
: configuration object for scripts that execute before a compilation. Default:
{
scripts: [],
blocking: false,
parallel: false
}
onBuildEnd
: configuration object for scripts that execute after files are emitted at the end of the compilation. Default:
{
scripts: [],
blocking: false,
parallel: false
}
onBuildExit
: configuration object for scripts that execute after webpack's process is complete. Note: this event also fires inwebpack --watch
when webpack has finished updating the bundle. Default:
{
scripts: [],
blocking: false,
parallel: false
}
blocking (onBuildStart, onBuildEnd, onBuildExit)
: block webpack until scripts finish execution.parallel (onBuildStart, onBuildEnd, onBuildExit)
: execute scripts in parallel, otherwise execute scripts in the order in which they are specified in the scripts array.
Note: below combination is not supported.
{
blocking: true
parallel: true
}
dev
: switch for development environments. This causes scripts to execute once. Useful for running HMR on webpack-dev-server or webpack watch mode. Default: truesafe
: switches script execution process from spawn to exec. If running into problems with spawn, turn this setting on. Default: falseverbose
: DEPRECATED enable for verbose output. Default: false