CLI tool
webpack/webpack-dev-server avatar
webpack/webpack-dev-server

webpack-dev-server: what it does, how to run it, and when webpack's dev server is the wrong tool

Serves a webpack app. Updates the browser on changes. Documentation https://webpack.js.org/configuration/dev-server/.

7,837 stars1,492 forksJavaScriptMIT

At a glance

What is it?
webpack-dev-server serves webpack output from memory and updates the browser on changes. It is a development-only tool, and the README is explicit about that boundary.
Who is it for?
Adopt webpack-dev-server if you already build with webpack and want in-memory serving plus live reloading without writing your own file watcher and socket layer. Do not adopt it as a production server: the README states it should be used for development only, and the assets it serves come from memory rather than disk.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 1 day ago.
What is it written in?
Mainly JavaScript, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 29, 2026, and from our analysis. They are not legal advice.

Editorial analysis

The problem webpack-dev-server solves for webpack users

A webpack build ends with files on disk. During development that is the wrong shape: you rebuild, you wait for a write, you reload the page by hand, and you repeat it hundreds of times a day. webpack-dev-server removes the disk step and the manual reload. The README describes it as a development server that provides live reloading, and says it uses webpack-dev-middleware under the hood, which provides fast in-memory access to the webpack assets. That sentence is the whole design in miniature: the bundle is held in memory by middleware, and a client script in the browser talks back to the server so the page updates when a compilation finishes.

The intended audience is narrow and clear. If your project already has a webpack configuration and you want a local server that reflects edits, this is the officially maintained path. If you build with something else, or you only need a static file server, the project offers nothing you cannot get from a two-line script. The README also fixes the scope at the top: this should be used for development only. That is not a disclaimer bolted on at the end; it shapes what the tool is good at and what it is not.

In-memory assets, the client script, and the reload path

The architecture has three moving parts. The first is webpack itself, running in watch mode, recompiling when files change. The second is webpack-dev-middleware, which intercepts requests and serves the current compilation from memory instead of from the output directory. The third is the client, a script injected into the served page. The README lists client options in the CLI help, including client-logging for the browser log level, client-overlay for a full-screen overlay on compiler errors or warnings, client-progress for a compilation percentage in the browser, and client-reconnect, which the help text describes as the number of times the client should try to reconnect.

That option list tells you where the failure modes live. A dev server that appears to hang is often a client that has lost its socket and is counting reconnects. An overlay covering the page is the client-overlay behaviour doing its job. The server side is configurable too: allowed-hosts controls which hosts may reach the dev server, and the help text notes the default is auto and that the option is useful when you are proxying the dev server. bonjour broadcasts the server over ZeroConf networking on start. None of these are cosmetic; they are the knobs that decide whether a container, a proxy or a second machine on your network can reach the running server at all.

Installing webpack-dev-server and starting it for the first time

The README gives three package manager variants and recommends a local install. The note is specific: while you can install and run webpack-dev-server globally, the project recommends installing it locally, and the server will always use a local installation over a global one. That last part matters in CI and in monorepos, where a stray global copy would otherwise shadow the version your project pins.

bash
npm install webpack-dev-server --save-dev

The yarn and pnpm equivalents are `yarn add -D webpack-dev-server` and `pnpm add -D webpack-dev-server`. After installation, the easiest way to run it is through the webpack CLI, from the directory that holds your webpack.config.js.

bash
npx webpack serve

The README notes that `serve`, `server` and `s` are accepted spellings of the same command. What you should see is a compilation, then a local URL you can open in a browser. Edit a source file and the page updates without a manual refresh. If you would rather drive it from code, the API form is the other documented route, and the repository ships a TypeScript entry point at types/lib/Server.d.ts for typed usage. The examples directory contains working setups for the common cases, including examples/hmr, examples/proxy, examples/host-and-port and examples/compression, which is a faster starting point than assembling options from the CLI help.

Stopping, restarting and the traps around allowedHosts

Because the server runs in the foreground, stopping it is a matter of ending the process the way you started it, typically Ctrl+C in the terminal running `npx webpack serve`. The README does not document a shutdown command or a graceful drain, so there is nothing project-specific to reach for beyond terminating the process. Restarting is the same command again. In a container, that means the process is the container's foreground job and its exit is the container's exit.

The more interesting trap is host checking. allowed-hosts defaults to auto, and the help text frames the option as useful when you are proxying the dev server. If you put the dev server behind a reverse proxy, a tunnel or a container hostname, the browser's Host header will not match what the server expects, and requests get rejected before your app ever loads. The fix is to enumerate the hosts explicitly, either through the CLI option or the corresponding configuration key, and the README provides `--allowed-hosts-reset` for clearing items already provided. This is a security control doing its job, not a bug, but it is the single most common reason a dev server that works on localhost fails behind infrastructure.

Where webpack-dev-server is the wrong tool

The README's own instruction settles the largest case: development only. Do not point this at production traffic. Assets live in memory, there is no documented production hardening story in the README, and the client overlay and reconnect machinery exist to help a human at a keyboard. If you need to serve built files, you want a static server or your application server, not this.

The second case is subtler. webpack-dev-server is a webpack plugin-shaped tool, so it inherits webpack's configuration surface. That is a benefit when your build is already webpack and a cost when it is not. If your project has moved to a bundler with its own dev server, adding webpack-dev-server back means maintaining a second build graph purely for local development. The repository acknowledges this kind of transition in a different direction: it ships migration-v4.md, migration-v5.md and migration-v6.md, which exist because upgrading the dev server across major versions is a real task with breaking changes, not a version bump you can ignore. Anyone planning an upgrade should read the relevant migration file before touching package.json.

webpack dev server vs Vite: the difference is the build model

People searching for a comparison usually want to know whether the dev server choice is separable from the bundler choice. It is not, and that is the honest answer. webpack-dev-server compiles with webpack and serves the resulting assets from memory through webpack-dev-middleware. Vite takes a different route: it serves source modules to the browser during development and relies on the browser's native module handling, reserving a full bundle for production. The practical consequence is that webpack-dev-server's dev experience is bounded by how fast webpack can produce a compilation, while Vite's is bounded by how fast the browser can request modules.

That difference does not make one strictly better. webpack-dev-server's advantage is that development and production run through the same compiler and the same configuration, so the thing you debug locally is produced by the same pipeline that ships. Vite's advantage is startup time on large dependency graphs. If your project is already webpack and the build works, switching dev servers means switching bundlers, which is a much larger decision than the search query implies. If you are starting fresh and have no webpack investment, the dev server is not the axis to optimize first.

Maintenance, version history and the MIT licence

The project is not archived, and its last push was on 2026-09-21. The v6.0.0 release is dated 2026-07-03, with v5.2.6 and v5.2.5 preceding it in June and early July 2026. The presence of a v6 line alongside a still-patched v5 line means the project is maintaining both branches, so a team on v5 is not stranded, but the migration-v6.md file in the repository root indicates that moving to 6.0.0 involves changes worth reading about in advance.

Licensing is MIT, declared in package.json and in the LICENSE file. MIT is permissive: it allows use, modification and redistribution with the copyright notice and permission notice retained. That is a statement about the licence text, not legal advice for your situation, and any organisation with a licence review process should run it through that process rather than treating this paragraph as clearance. The upgrade cost is the part worth budgeting. The CLI surface is large, the client and server options are numerous, and the migration documents exist because behaviour has changed across majors. A pinned version with a scheduled upgrade window is a cheaper arrangement than upgrading opportunistically when a build breaks.

Editorial conclusion

Adopt webpack-dev-server if you already build with webpack and want in-memory serving plus live reloading without writing your own file watcher and socket layer. Do not adopt it as a production server: the README states it should be used for development only, and the assets it serves come from memory rather than disk. Before upgrading, read migration-v6.md, check the v6.0.0 release notes, and confirm whether your allowedHosts and client reconnect settings still behave the way your setup depends on.

Frequently asked questions

What is the webpack development server?

It is a development server that runs webpack and provides live reloading, serving the compiled assets from memory through webpack-dev-middleware. The README states it should be used for development only.

How do I install webpack dev server?

The README gives `npm install webpack-dev-server --save-dev`, with `yarn add -D webpack-dev-server` and `pnpm add -D webpack-dev-server` as alternatives. It recommends a local install because the server always prefers a local installation over a global one.

How do I start webpack dev server?

From the directory containing your webpack.config.js, run `npx webpack serve`. The README notes that `serve`, `server` and `s` all work as the command name.

How do I stop webpack dev server?

It runs in the foreground, so ending the process, usually with Ctrl+C in the terminal running `npx webpack serve`, stops it. The README does not document a dedicated shutdown command.

How do I run webpack dev server?

The README's recommended route is the webpack CLI: run `npx webpack serve` in the directory where your webpack.config.js lives. The API form is also documented for driving the server from code.

How do I upgrade webpack dev server?

The repository ships migration-v4.md, migration-v5.md and migration-v6.md at its root, and v6.0.0 was released on 2026-07-03. The README does not summarise the breaking changes, so the migration file for your target major is the place to check first.

Official sources

  1. Issues
  2. License: MIT
  3. README
  4. Releases
  5. webpack/webpack-dev-server on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/webpack-webpack-dev-server.svg)](https://hysenlabs.com/projects/webpack-webpack-dev-server)