Search code examples
webpackvue.jsvuejs2lazy-loadingwebpack-2

How to separate node modules from async chunks in webpack?


My webpack config has vendor chunk, which is separated from main bundle. However, since I'm using lazy loading on routes as well, I need to be able to separate rest of node modules from those lazy loading chunks also. I tried with this:

new webpack.optimize.CommonsChunkPlugin({
      async: 'used-twice',
      // children: true,
      minChunks(module, count) {
          return count >= 2;
      },
  }),

but it does nothing.

Help is appreciated.


Solution

  • Updated webpack version to 3.10.0 and it works.