I get the general gist that the So, let's assume I have the following configuration:
If I bundle without using
|
shareimprove this question |
edited Nov 3 at 18:44 |
asked Sep 17 at 14:53 Dimitris Karagiannis 1,986426 |
|
For case 1 I think you should specify the minChunks property. – Marko Sep 19 at 16:19 |
add a comment
1 Answer
activeoldestvotes
up vote12down voteaccepted
+50 |
This is how the CommonsChunkPlugin works. A common chunk "receives" the modules shared by several entry chunk. A good example of a complex configuration can be found in the WebPack repository. The CommonsChunkPlugin is run during the optimization phase of WebPack, which means that it operates in memory, just before the chunk are sealed and written on the disk. Where several common chunks are defined, they are processed in order. In your case 3, it is like running the plugin twice. But please note that the CommonsChunkPlugin can have a more complex configuration (minSize, minChunks, etc) that impacts the way modules are moved. CASE 1:
entry chunks (entry1 , entry2 and vendors )The configuration sets the commons chunk as a common chunkThe plugin processes the commons common chunk (since the chunk does not exist, it is created):
entry1 , entry2 and vendors use jquery so the module is removed from these chunks and is added to the commons chunk.The commons chunk is flagged as an entry chunk while the entry1 , entry2 and vendors are unflagged as entry .Finally, since the CASE 2:
entry chunks (entry1 , entry2 and vendors )The configuration sets the vendors chunk as a common chunkThe plugin processes the vendors common chunk:
entry1 and entry2 use jquery so the module is removed from these chunks (note that it is not added to the vendors chunk because the vendors chunk already contains it).The vendors chunk is flagged as an entry chunk while the entry1 and entry2 are unflagged as entry .Finally, since the CASE 3:
entry chunks (entry1 , entry2 and vendors )The configuration sets the vendors chunk and the manifest chunk as a common chunks.The plugin creates the manifest chunk as it doesn't existThe plugin processes the vendors common chunk:
entry1 and entry2 use jquery so the module is removed from these chunks (note that it is not added to the vendors chunk because the vendors chunk already contains it).The vendors chunk is flagged as an entry chunk while the entry1 and entry2 are unflagged as entry .The plugin processes the
The manifest chunk is flagged as entry chunk while the entry1 , entry2 and vendors are unflagged as entry .Finally, since the Hope it helps. |
http://stackoverflow.com/questions/39548175/can-someone-explain-webpacks-commonschunkplugin/39600793