Quantcast
Viewing latest article 3
Browse Latest Browse All 4

Answer by WelcomeTo for How to configure webpack 4 to prevent chunks from list of entry points appearing in any other bundle?

Our goal is to configure webpack to build our assets so that any chunks that appear in any of these bundles will not appear in any other bundle.

What I had before:

            new webpack.optimize.CommonsChunkPlugin({                name: 'vendor',                minChunks: function (module, count) {                    // this assumes your vendor imports exist in the node_modules directory and module should be required                    // in at least 3 entries before it moved to common chunk                    return (module.context && module.context.indexOf('node_modules') !== -1) && count > 2;                }            }),

How it works now:

        optimization: {            splitChunks: {                cacheGroups: {                    vendor: {                        test: /[\\/]node_modules[\\/]/,                        chunks: 'all',                        name: 'vendor',                        enforce: true,                        minChunks: 3                    }                }            }        },

Viewing latest article 3
Browse Latest Browse All 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>