Webpack SplitChunksPlugin - exclude one entry point entirely
Asked Answered
S

0

6

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?

Sikes answered 22/9, 2020 at 11:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.