Skip to content

Commit 6f33e11

Browse files
refactor: avoid unnecessary code and prepare to plugin usage (#3714)
1 parent 110f127 commit 6f33e11

14 files changed

+778
-894
lines changed

lib/Server.js

Lines changed: 378 additions & 76 deletions
Large diffs are not rendered by default.

lib/utils/DevServerPlugin.js

Lines changed: 0 additions & 352 deletions
This file was deleted.

migration-v4.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,38 @@ module.exports = {
521521

522522
- The `sockWrite` public method was renamed to `sendMessage`.
523523
- The `profile` option was removed in favor [`ProfilingPlugin`](https://webpack.js.org/plugins/profiling-plugin/).
524+
- The `addDevServerEntrypoints` method was removed in favor of manual configuration.
525+
526+
v4:
527+
528+
```js
529+
const webpack = require("webpack");
530+
const DevServer = require("webpack-dev-server");
531+
532+
const config = {
533+
entry: [
534+
// Runtime code for hot module replacement
535+
"webpack/hot/dev-server.js",
536+
// Dev server client for web socket transport, hot and live reload logic
537+
"webpack-dev-server/client/index.js?hot=true&live-reload=true",
538+
// Your entry
539+
"./src/entry.js",
540+
],
541+
plugin: [
542+
// Plugin for hot module replacement
543+
new webpack.HotModuleReplacementPlugin(),
544+
],
545+
};
546+
const compiler = webpack(config);
547+
// `hot` and `client` options are disabled because we added them manually
548+
const server = new DevServer({ hot: false, client: false }, compiler);
549+
550+
(async () => {
551+
await server.start();
552+
553+
console.log("Running");
554+
})();
555+
```
524556

525557
### Deprecations
526558

0 commit comments

Comments
 (0)