{"id":24986908,"url":"https://github.com/wspl/webpack-server-kit","last_synced_at":"2026-04-11T01:46:52.012Z","repository":{"id":83993209,"uuid":"173547148","full_name":"wspl/webpack-server-kit","owner":"wspl","description":"[WIP] A re-implementation of webpack development server library","archived":false,"fork":false,"pushed_at":"2019-03-05T03:45:01.000Z","size":70,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T20:40:54.220Z","etag":null,"topics":["dev","express","hot","hot-reload","koa","middleware","webpack"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wspl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-03T08:03:07.000Z","updated_at":"2019-03-05T04:44:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"530cda6e-15cc-41ec-bb36-76895d1160b8","html_url":"https://github.com/wspl/webpack-server-kit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wspl%2Fwebpack-server-kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wspl%2Fwebpack-server-kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wspl%2Fwebpack-server-kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wspl%2Fwebpack-server-kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wspl","download_url":"https://codeload.github.com/wspl/webpack-server-kit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246174539,"owners_count":20735413,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dev","express","hot","hot-reload","koa","middleware","webpack"],"created_at":"2025-02-04T11:33:25.590Z","updated_at":"2026-04-11T01:46:46.986Z","avatar_url":"https://github.com/wspl.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# webpack-server-kit\nA re-implementation of webpack development server logic.\n\nYou can create a webpack development server with this library on any server framework. In addition, this library supports working on subdirectory.\n\nOf course, We provide the out-of-the-box middleware for express and koa.\n\nThis is an alternative (in a sense) of `webpack-dev-middleware` and `webpack-hmr-midlleware`.\n\n## Middleware\nIf you plan to use it directly on Koa and Express, please refer to:\n\n- [Express](packages/express)\n- [Koa](packages/koa)\n\n## Usage\nWe will show you how to integrate this library with other web servers.\n\nHere we use Node's native http module as an example.\n\nFirst, install the core library:\n\n```bash\nnpm install @webpack-server-kit/core\n# or use yarn:\nyarn add @webpack-server-kit/core\n```\nNext, create service contexts and modify server's response handler:\n```javascript\nimport http from 'http'\nimport { DevContext, HmrContext } from '@webpack-server-kit/core'\n\n// Need a webpack compiler instance can be passed to contexts.\nconst compiler = {/* webpack.Compiler */}\n\n// Dev server support: serve the webpack compiled files.\nconst dev = new DevContext(compiler)\n// Hmr support: enable hmr service.\nconst hmr = new HmrContext(compiler)\n\n// Create a server with an asynchronous request handler.\nhttp.createServer(async (req, res) =\u003e {\n  // Handle the request and\n  // pass http.IncomingRequest to request parameter.\n  const devSession = dev.incoming({request: req})\n  const hmrSession = hmr.incoming({request: req})\n  \n  // Determine which service this request matches\n  const session = await devSession.test() ? devSession\n    : await hmrSession.test() ? hmrSession\n    : null\n    \n  if (session) {\n    session.on('headers', (headers, status) =\u003e {\n      res.set(headers)\n      res.status(status)\n    })\n    session.pipe(res)\n    // Respond to request.\n    // (Must be after the bind operations)\n    await session.run()\n  } else {\n    // Handling requests outside of the service,\n    // such as handling server-side rendering logic or returning 404.\n  }\n}).listen(3000)\n```\nThen you need to enable hot module replacement (if you need) in your webpack config:\n\n1. Add HMR plugin to the plugins array:\n    ```javascript\n    plugins: [\n      new webpack.HotModuleReplacementPlugin(),\n    ]\n    ```\n\n2. Add `webpack-hot-middleware/client` into the entry array.\n\n    ```javascript\n    entry: [\n     'webpack-hot-middleware/client',\n     'index.js' // or your custom entry\n    ]\n    ```\n\n    This step relies on the original [webpack-hot-middleware](https://github.com/webpack-contrib/webpack-hot-middleware) library, so you need to add it as a dependency. (We plan to re-implement the client entry as a part of this library before the stable release.)\n\n## API\nWork in progress.\n\n## License\nSee [LICENSE file](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwspl%2Fwebpack-server-kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwspl%2Fwebpack-server-kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwspl%2Fwebpack-server-kit/lists"}