1
react-dnd
과 두 개의 react-dnd
백분율로 하나의 비동기 공통 청크를 만들고 나머지 모든 노드 유틸리티 (두 번째는 node_modules
에 있음)로 두 번째를 만들려고합니다.비동기 WebPack CommonsChunk 전체 npm 모듈을 사용하여
코드는 다음과 같습니다. 내 react-dnd
번들 은에 3 개의 npm
유틸리티가 있지만 그게 전부입니다. 그것은 그 종속이 포괄 번들에있는 사람들 유틸리티 dnd-core
처럼 의존 하는 일 등, all-node
내가 무엇을 찾고 달성하기위한 가장 간단한 방법은 무엇을하지 않는 이유는 무엇입니까?
new webpack.optimize.CommonsChunkPlugin({
filename: 'all-node.js',
async: 'all-node',
minChunks(module, count) {
var context = module.context;
return context && context.indexOf('node_modules') >= 0;
},
}),
new webpack.optimize.CommonsChunkPlugin({
chunks: ['react-dnd'],
filename: 'react-dnd.js',
async: 'react-dnd',
children: true,
minChunks(module, count) {
var context = module.context;
var targets = ['react-dnd', 'react-dnd-html5-backend', 'react-dnd-touch-backend']
return count > 1 || (context && context.indexOf('node_modules') >= 0 && targets.find(t => new RegExp('\\\\' + t + '\\\\', 'i').test(context)));
},
}),