Skip to content

Commit 98f314a

Browse files
authored
Mention runtimeChunk: single for multi-endpoint dev server
This section of the guide introduces the concept of a dev server for the first time, but has not introduced the concept that multiple endpoints on a single html file served by the webserver is problematic without `optimization.runtimeChunk: 'single'`. This commit attempts to give new developers a softer landing, and references the Code Splitting section to more deeply understand as well as link to the same pitfall external resource as the Code Splitting section does. See webpack/webpack#14873 (comment) for rationale
1 parent de5d89f commit 98f314a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/content/guides/development.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,16 @@ Change your configuration file to tell the dev server where to look for files:
225225
path: path.resolve(__dirname, 'dist'),
226226
clean: true,
227227
},
228+
+ optimization: {
229+
+ runtimeChunk: 'single',
230+
+ },
228231
};
229232
```
230233

231234
This tells `webpack-dev-server` to serve the files from the `dist` directory on `localhost:8080`.
232235

236+
The `optimization.runtimeChunk: 'single'` was added because in this example we have more than one entrypoint on a single HTML page. Without this, we could get into trouble described [here](https://bundlers.tooling.report/code-splitting/multi-entry/). Read the [Code Splitting](/guides/code-splitting/) section of the guide for more details.
237+
233238
T> `webpack-dev-server` serves bundled files from the directory defined in [`output.path`](/configuration/output/#outputpath), i.e., files will be available under `http://[devServer.host]:[devServer.port]/[output.publicPath]/[output.filename]`.
234239

235240
W> webpack-dev-server doesn't write any output files after compiling. Instead, it keeps bundle files in memory and serves them as if they were real files mounted at the server's root path. If your page expects to find the bundle files on a different path, you can change this with the [`devMiddleware.publicPath`](/configuration/dev-server/#devserverdevmiddleware) option in the dev server's configuration.

0 commit comments

Comments
 (0)