Do you want to request a feature or report a bug?
What is the current behavior?
RT
If the current behavior is a bug, please provide the steps to reproduce.
I have a multi Page app and I have two enties ‘main.js’,’main2.js’ for two pages.
//main.js
require(['./a','./b','./c'],function(){
console.log('main')
})
//main2.js
require(['./a','./b','./d'],function(){
console.log('main')
})
as you see. two entries share common ‘./a’, ‘,/b’.
if bundle the code now , ‘./a’, ‘,/b’ will apear twice , result in large file size if they are big files
then I want to use CommonsChunksPlugins to remove duplicate module like
//webpack.config.js
new webpack.optimize.CommonsChunkPlugin({
async: true,
minChunks: 2
})
nothing change… then i change to
entry:{
main:'./main.js',
main2:'./main2.js',
common:['./a','./b']
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: ['share','common'],
async: true,
minChunks: 2
})
]
this time it generate share.js contain ‘./a’, ‘,/b’.
but entries main.js and main2.js still contain ‘./a’, ‘,/b’. it does not reduce ouptsize
What is the expected behavior?
extract common modules from entries to #share.js
Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.
Window10
Webpack 2.2.0
node 6.9.2
@jjaskulowski you’re using
children: true
with the CommonsChunkPlugin. @sokra explains the effect of this in #3981@githoniel The problem is that your are using
async:true
. That option also enableschildren:true
. So the plugin will extract commons dependencies from the chunk’s children you have specified in the name option of the plugin.If you set
async:false
o remove it, it will work