File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -337,17 +337,21 @@ app.use(middleware(compiler, { serverSideRender: true }))
337
337
// The following middleware would not be invoked until the latest build is finished.
338
338
app .use ((req , res ) => {
339
339
const assetsByChunkName = res .locals .webpackStats .toJson ().assetsByChunkName
340
+ const fs = res .locals .fs
341
+ const outputPath = res .locals .webpackStats .toJson ().outputPath
340
342
341
343
// then use `assetsByChunkName` for server-sider rendering
342
344
// For example, if you have only one main chunk:
343
345
res .send (`
344
346
<html>
345
347
<head>
346
348
<title>My App</title>
349
+ <style>
347
350
${ normalizeAssets (assetsByChunkName .main )
348
351
.filter (path => path .endsWith (' .css' ))
349
- .map (path => ` <link rel="stylesheet" href=" ${ path } " /> ` )
352
+ .map (path => fs . readFileSync (outputPath + ' / ' + path) )
350
353
.join (' \n ' )}
354
+ </style>
351
355
</head>
352
356
<body>
353
357
<div id="root"></div>
You can’t perform that action at this time.
0 commit comments