I am currently trying to code split for react server side rendering. Everything works fine except the refreshing part. When I refresh the page, Everything shows in server side. However, the split second right before client side takes over the lazy loading component is gone then it show up when client side start rendering again.
"webpack": "^4.4.0", "mini-css-extract-plugin": "^0.4.0",
react-loadable.json part
{
"undefined": [
{
"id": 2,
"name": null,
"file": "styles.css",
"publicPath": "/dist/styles.css"
}
...
]
}
webpack chunk option for style styles: { name: 'styles', test: /.css$/, chunks: 'all', enforce: true },
Server.js react-loadable setup part
let modules = []
const context = {}
const htmlRoot = (
<Provider store={store}>
<StaticRouter location={urlPath} context={context}>
<Loadable.Capture report={moduleName => modules.push(moduleName)}>
<AppRoot />
</Loadable.Capture>
</StaticRouter>
</Provider>
)
const bundles = getBundles(stats, modules)
console.log(bundles, modules)
Even though all the pages are loaded correctly, the bundles variables are always empty array. Anyone know how to fix this problem? or what might cause this problem?