This document serves as a migration guide for webpack-dev-server@6.0.0.
-
Minimum supported
Node.jsversion is22.15.0. -
Minimum supported
webpackversion is5.101.0. -
The package is now published as ESM-only. Prefer
importsyntax. CommonJS consumers can still load it viarequire(esm), which is enabled by default in the supported Node.js versions (>= 22.15.0). -
webpack-dev-middlewarehas been upgraded to v8. The most notable change for consumers is thatserver.middleware.getFilenameFromUrl()is now asynchronous and resolves to an object{ filename, extra: { stats, outputFileSystem } }instead of returning the filename synchronously. See the webpack-dev-middleware v8 release notes for the full list of changes. -
The bundled Express has been upgraded to v5. This affects
setupMiddlewares, theappoption, and any custom middleware integration. Notably: path matching no longer supports the bare*wildcard (use*splator named parameters),req.queryis no longer mutable, and rejected promises in middleware are now forwarded to error handlers automatically. See the Express 5 migration guide for the full list of breaking changes. -
Support for SockJS in the WebSocket transport has been removed. Now, only native WebSocket is supported, or custom client and server implementations can be used.
-
The options for passing to the
proxyhave changed. Please refer to the http-proxy-middleware migration guide for details. -
Remove support for the spdy server type.Use the http2 server type instead; however, since Express does not work correctly with it, a custom server (e.g., Connect or Hono) should be used.
v4:
module.exports = { // ... devServer: { server: "spdy", }, };
v5:
const connect = require("connect"); module.exports = { // ... devServer: { server: { server: "http2", app: () => connect(), }, }, };
-
Now, webpack-dev-server adds WebSocket communication only when the
targetis set to a web-compatible environment. Previously, it also injected WebSocket communication ifresolvecontained aconditionNamesentry withbrowseror ifexternalsPresets.webexisted. -
When retrieving the configuration in a multi-compiler setup, it will look for one that has a target compatible with a web environment. If it doesn’t find one, it will fall back to the first compiler found by webpack.
-
The static methods
internalIPandinternalIPSyncwere removed. UsefindIpinstead.v4:
const ip = Server.internalIP("v4");
v5:
const ip = Server.findIp("v4", true);
-
Support for webpack-dev-server using CLI flags has been removed. Please use the latest version of webpack-cli.
-
The bypass function in the proxy configuration was removed. Use the
pathFilterandrouterfor similar functionality. See the example below.v4:
module.exports = { // ... devServer: { proxy: [ { context: "/api", bypass(req, res, proxyOptions) { if (req.url.startsWith("/api/special")) { return "/special.html"; } }, }, ], }, };
v5:
module.exports = { // ... devServer: { proxy: [ { pathFilter: "/api/special", router: () => "http://localhost:3000", // Original Server pathRewrite: () => "/special.html", }, ], }, };
When
bypasswas used and that function returned a boolean, it would automatically result in a404request. This can’t be achieved in a similar way now, or, if it returned a string, you can do what was done in the example above.bypassalso allowed sending data; this can no longer be done. If you really need to do it, you’d have to create a new route in the proxy that sends the same data, or alternatively create a new route on the main server and, following the example above, send the data you wanted.