Skip to content

Commit

Permalink
docs(readme): correct dev middleware context usage (#1485)
Browse files Browse the repository at this point in the history
  • Loading branch information
MDAkramSiddiqui committed Mar 15, 2023
1 parent a2ebecc commit 032d90a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Expand Up @@ -398,8 +398,8 @@ In order to develop an app using server-side rendering, we need access to the
[`stats`](https://github.com/webpack/docs/wiki/node.js-api#stats), which is
generated with each build.

With server-side rendering enabled, `webpack-dev-middleware` sets the `stats` to `res.locals.webpack.devMiddleware.context.stats`
and the filesystem to `res.locals.webpack.devMiddleware.context.outputFileSystem` before invoking the next middleware,
With server-side rendering enabled, `webpack-dev-middleware` sets the `stats` to `res.locals.webpack.devMiddleware.stats`
and the filesystem to `res.locals.webpack.devMiddleware.outputFileSystem` before invoking the next middleware,
allowing a developer to render the page body and manage the response to clients.

_Note: Requests for bundle files will still be handled by
Expand Down Expand Up @@ -433,8 +433,8 @@ app.use(middleware(compiler, { serverSideRender: true }));
// The following middleware would not be invoked until the latest build is finished.
app.use((req, res) => {
const { devMiddleware } = res.locals.webpack;
const outputFileSystem = devMiddleware.context.outputFileSystem;
const jsonWebpackStats = devMiddleware.context.stats.toJson();
const outputFileSystem = devMiddleware.outputFileSystem;
const jsonWebpackStats = devMiddleware.stats.toJson();
const { assetsByChunkName, outputPath } = jsonWebpackStats;

// Then use `assetsByChunkName` for server-side rendering
Expand Down

0 comments on commit 032d90a

Please sign in to comment.