run-script-webpack-plugin is a utility Webpack plugin designed to automatically execute a specified script after Webpack completes its build process, primarily intended for development environments. As of its current stable version, 0.2.3, published approximately a year ago, the project appears to maintain a stable and perhaps slower release cadence. This plugin is particularly useful for server-side bundles, enabling automatic restarts or reloads during development workflows. A key differentiator is its strong TypeScript typing, having been re-implemented from scratch based on the functionality of start-server-webpack-plugin. It offers configurable options for passing arguments to Node.js and the script, managing auto-restarts, sending signals for Hot Module Reloading (HMR), and enabling keyboard-initiated restarts. [1, 2]
npm install run-script-webpack-pluginVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to integrate `RunScriptWebpackPlugin` into a Webpack configuration to automatically run a compiled server-side script, enable debugging, and configure HMR signals for development.
Ensure the plugin is conditionally included in your Webpack configuration only for `development` mode or when `process.env.NODE_ENV === 'development'`.
Modify your `webpack-node-externals` configuration to include these modules in its whitelist, e.g., `whitelist: ['webpack/hot/poll', /^webpack\/hot\//]`.
Consult the `webpack` migration guides (e.g., `webpack-cli` changelog for Node.js and Webpack version requirements) and ensure your Webpack version and configuration align with the plugin's expected environment. [5, 8]
Provide the `name` option to `RunScriptWebpackPlugin` matching the desired entry point's output filename, e.g., `new RunScriptWebpackPlugin({ name: 'server.js' })`.Ensure `webpack/hot/poll` or `webpack/hot/signal` are explicitly whitelisted in your `webpack-node-externals` configuration.