Please tell me how to extract common code from webpack4.

in webpack 4, CommonsChunkPlugin, was deleted and replaced by optimization.splitChunks
Baidu checked the introduction of splitChunks and tried for a long time to extract the public jq library. I would like to ask the bosses, can you provide a specific way to extract the public jq library from webpack 4? thank you

Mar.01,2021

module.exports = {
    entry: {
        task: path.join(__dirname, 'src', 'xxx', 'index.js')
    },
    optimization: {
        splitChunks: {
            cacheGroups: {
                vendor: {
                    test: /[\\/]node_modules[\\/]/,
                    name: 'common',
                    priority: 10,
                    chunks: 'all'
                }
            }
        }
    },
    output: {
        path: path.join(__dirname, 'public'),
        filename: 'bundle.[name].[hash:8].js'
    },
    ...
Menu