如果以下配置使用 nodeExternals,则无法生成公共块,我的问题是如何在使用 nodeExternals 时对供应商代码进行分块?
webpack.config.js
const nodeExternals = require('webpack-node-externals');
module.exports = {
name: 'server',
target: 'node',
mode: 'development',
entry: './index.js',
optimization: {
runtimeChunk: {
name: 'runtime',
},
splitChunks: {
chunks: 'all',
cacheGroups: {
commons: {
chunks: 'all',
test: /[\\/]node_modules[\\/]/,
enforce: true,
},
},
},
},
externals: [nodeExternals()],
module: {
rules: [
{
oneOf: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
loader: require.resolve('babel-loader'),
},
],
},
],
},
};