Search code examples
javascriptwebpackreact-routerwebpack-2code-splitting

Webpack: extract text plugin and code splitting


I'm trying to setup my build system with webpack to do route based code splitting (I'm using react-router and webpack 2.2).

Everything went pretty smoothly, found some examples online, the problem I hit is with the CSS. I'm using ExtractTextPlugin to extract my css in a separate file. The problem is that it only extracts the css from the main bundle, it doesn't extract the css found in the rest of the chunks.

What I would like would be to extract all the styles in the css file to be able to load that and cache it separately.

Any ideas? Thanks!


Solution

  • According to https://webpack.js.org/plugins/extract-text-webpack-plugin/ you have to set allChunks: true. If this is not working, please post your config, it is hard to guess what your setup looks like.