在Webpack 4中,我试图将node_modules
中的一个包及其所有依赖项分离到一个块中,而不是将其合并到vendor
块中。
我能得到的最接近的结果是使用以下方法拆分包本身(不包括依赖项):
module.exports = {
//...
optimization: {
splitChunks: {
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/](react|react-dom)[\\/]/,
name: 'vendor',
chunks: 'all',
}
}
}
}
};
就像SplitChunksPlugin example #3
中的示例一样试图检查module
的{{1}}函数中的chunk
和cacheGroup
参数,但是我似乎找不到如何做的线索,有没有人尝试做同样的事情并成功?
谢谢!