razzle-start-server-webpack-plugin is a utility designed to automatically start a Node.js server after Webpack completes its build process, primarily for server-side bundles in development. It also integrates seamlessly with Hot Module Reloading (HMR) for server code, eliminating the need for manual server restarts during development. The current stable version is 4.2.18, released as part of the broader Razzle monorepo, indicating its release cadence is tied to Razzle's development lifecycle. Its key differentiators include simplified HMR setup for server code and the ability to pass arguments directly to Node.js or the server script, making debugging easier.
npm install razzle-start-server-webpack-pluginVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates configuring Webpack to use `StartServerPlugin` for a Node.js server, enabling automatic restarts and Hot Module Replacement during development, including debugging with Node.js inspector.
Replace `new StartServerPlugin({ name: 'my-server' })` with `new StartServerPlugin({ entryName: 'my-server' })`.Conditionally apply the plugin using `if (process.env.NODE_ENV === 'development') { /* add plugin */ }` in your webpack config.Remove redundant HMR entry points if you observe unexpected behavior or double HMR messages. Ensure `webpack.HotModuleReplacementPlugin()` is still included.
Upgrade to `razzle-start-server-webpack-plugin@4.2.18` or newer if you are using Node.js ESM modules for your Razzle/Webpack configuration.
Use `import StartServerPlugin from 'start-server-webpack-plugin';` instead of `const StartServerPlugin = require('start-server-webpack-plugin');` and ensure your webpack config supports ESM.Ensure `webpack` is installed as a peer dependency (e.g., `npm install webpack`) and that its version is compatible with the plugin (`~4||~5`).
Ensure `watch: true` is set in your Webpack config, `new webpack.HotModuleReplacementPlugin()` is included, and your server entry file includes `module.hot.accept();` logic if you want custom HMR handling.