Skip to content

Commit 2368346

Browse files
authored
docs(guides): Mention runtimeChunk: single for multi-endpoint dev server (#6098)
* 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 * Make it a tip, use "chapter" not "section" * Add self to contributors
1 parent 8cd11f4 commit 2368346

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/content/guides/development.mdx

+6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ contributors:
1616
- chenxsan
1717
- maxloh
1818
- snitin315
19+
- f3ndot
1920
---
2021

2122
T> This guide extends on code examples found in the [Output Management](/guides/output-management) guide.
@@ -225,11 +226,16 @@ Change your configuration file to tell the dev server where to look for files:
225226
path: path.resolve(__dirname, 'dist'),
226227
clean: true,
227228
},
229+
+ optimization: {
230+
+ runtimeChunk: 'single',
231+
+ },
228232
};
229233
```
230234

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

237+
T> 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/) chapter for more details.
238+
233239
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]`.
234240

235241
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)