I have been trying for a while now, to no avail, to get my configuration working for an app that has the following characterstics:
- Typescript
- React
- Server side rendering using loadable-components
- Webpack
For some reason, this snippet, which is supposed to find all the chunks that were used during the server side rendering, is not working:
server.get("*", (req, res, next) => {
const extractor = new ChunkExtractor({ statsFile });
...
const tsx = extractor.collectChunks(
<ChunkExtractorManager extractor={extractor}>
<StaticRouter location={req.url}>
<App data={data}/>
</StaticRouter>
</ChunkExtractorManager>
);
console.log(extractor.getScriptTags()); // prints server.js bundle but this isn't correct
});
It's returning the server.js
bundle instead of the needed client/vendor bundles. Rather than post all the code here, I've pushed all the code to my branch on github: https://github.com/markdstevens/ssr-ts-react-webpack-boilerplate/tree/ssr-with-code-splitting
I must be missing some configuration in webpack or in loadable-components, but I've looked everywhere and can't seem to find the issue. Any tips would be most welcome. Thanks!