V
V
Vladislav2019-12-28 12:28:38
webpack
Vladislav, 2019-12-28 12:28:38

Webpack CommonsChunkPlugin and splitChunks?

On webpack 3, I have this code snippet where CommonsCunkPlugin concatenates more than 2 modules or node_modules into one file

new webpack.optimize.CommonsChunkPlugin({
            name: 'commons',
            filename: '[name].js',
            minChunks: function(modules, quantity) {
                return modules.context && (modules.context.includes('node_modules') || quantity >= 2)
            }
        })

How to repeat the same on webpack 4 splitChunks
cacheGroups: {
                commons: {
                    name: 'commons',
                    filename: '[name].js',
                    test: function(modules) {
                        return modules.context && modules.context.includes('node_modules')
                    },
                    chunks: 'all'
                }
            }

It captures only node_modules, how can it condition "or"?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question