{"library":"start-server-webpack-plugin","title":"Start Server Webpack Plugin","type":"library","description":"start-server-webpack-plugin is a Webpack plugin designed to automatically launch a Node.js server process once Webpack's build completes, primarily for development environments. It allows developers to integrate server-side applications, such as Express, directly into their Webpack development workflow. The plugin supports features like Hot Module Replacement (HMR) for server-side code, debugging via Node.js arguments, and automatic server restarts on file changes. The current stable version is 2.2.5, however, the package has not been updated since March 2018, indicating it is no longer actively maintained. Newer Webpack versions (like Webpack 5) are not officially supported, leading users to seek alternatives or forks for compatibility. Key differentiators include its focused role in *starting* a server post-build, rather than providing a full development server like webpack-dev-server, and its ability to pass arguments directly to the Node.js process and the target script itself.","language":"javascript","status":"abandoned","last_verified":"Sun Apr 19","install":{"commands":["npm install start-server-webpack-plugin"],"cli":null},"imports":["import StartServerPlugin from 'start-server-webpack-plugin';","const StartServerPlugin = require('start-server-webpack-plugin');"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":null,"github":"https://github.com/ericclemmons/start-server-webpack-plugin","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/start-server-webpack-plugin","openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"const path = require('path');\nconst webpack = require('webpack');\nconst StartServerPlugin = require('start-server-webpack-plugin');\n\nmodule.exports = {\n  mode: 'development',\n  target: 'node',\n  entry: {\n    server: [\n      'webpack/hot/poll?1000',\n      path.resolve(__dirname, 'src', 'server.js'),\n    ],\n  },\n  output: {\n    path: path.resolve(__dirname, 'dist'),\n    filename: '[name].js',\n  },\n  watch: true,\n  externals: [\n    // In order to ignore all modules in node_modules folder from bundling\n    /^[a-z\\-0-9]+$/,\n  ],\n  plugins: [\n    // Only use this in DEVELOPMENT\n    new StartServerPlugin({\n      name: 'server.js', // Must match the output filename for the server entry\n      nodeArgs: ['--inspect'], // Allows attaching a Node.js debugger\n      args: ['--dev-mode'], // Pass custom arguments to your server script\n      signal: true, // Send SIGUSR2 to restart the server for HMR\n      keyboard: true, // Allow 'rs' to restart from terminal\n    }),\n    new webpack.HotModuleReplacementPlugin(),\n    new webpack.NoEmitOnErrorsPlugin(), // Good practice for HMR\n  ],\n};\n\n// src/server.js (example)\n// const express = require('express');\n// const app = express();\n// const port = process.env.PORT || 3000;\n\n// app.get('/', (req, res) => {\n//   res.send('Hello from server! Updated: ' + new Date().toLocaleTimeString());\n// });\n\n// app.listen(port, () => {\n//   console.log(`Server listening on port ${port}`);\n// });\n\n// if (module.hot) {\n//   module.hot.accept();\n//   module.hot.dispose(() => console.log('Server disposing...'));\n// }","lang":"javascript","description":"This quickstart demonstrates a typical Webpack configuration using `start-server-webpack-plugin` to compile and launch a Node.js server. It includes basic Hot Module Replacement (HMR) setup, debugging flags, and an example server structure.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}