Webpack SplitChunksPlugin - exclude one entry point entirely

379 views Asked by At

I am using SplitChunksPlugin with Webpack 4 through Rails + Webpacker.

I have an app that I want to split into chunks - except for one entry point which is for the public that I want to be a self contained, single file.

When I was previously using CommonsChunkVendor, I could do this:

var adminEntries = Object.keys(environment.entry).filter(function(e) { return e !== 'app' });

environment.plugins.append(
  'CommonsChunkVendor',
  new webpack.optimize.CommonsChunkPlugin({
    name: 'vendor',
    chunks: adminEntries,
    minChunks: (module) => {
      // this assumes your vendor imports exist in the node_modules directory
      return module.context && module.context.indexOf('node_modules') !== -1
    }
  })
)

This would exclude the 'app' entry point from being split.

How can I achieve this using SplitChunksPlugin?

0

There are 0 answers