Loading dependencies to a vendor Bundle Automatically
Closed this issue · 5 comments
Hi @bebraw, thanks for your commitment with the React/Webpack community! I learned a lot from Survive.js and with your "evolution" in the community!
I've a question, where I find myself struggling to make/find a good example of how to make it work,
In the Splitting Bundles chapter, we've a example of how to dynamic/automatically generate a "vendor" chunk based on the current entry:
We have a similar thread in the webpack tricks repository: rstacruz/webpack-tricks#1
Following the example from this comment,
Do you think would be possible to make this dynamic/automatically chunk generating based on multiple paths using CommonsChunkPlugin/minChunks?
Thanks!
Hi,
See here. I think you need to set chunks
array like in that example.
I think I'll add something along this to the book as it's a good question.
that's awesome @bebraw , following this thread I could make it work!
now I've a solid example of dynamic splitting with CommonsChunkPlugin:
https://github.com/oieduardorabelo/webpack-commonschunkplugin-dynamic-splitting
it fit my needs, the trick is the "chunk" key, really cool!
many thanks dude!
No probs. I'll close this and add the trick to the book.
chunks
is particularly useful for constraining CommonsChunkPlugin
behavior. In your earlier example the first plugin processed it all. That's why it didn't get to the latter ones.
@bebraw - please see my comment here, I think we're still not able to create the vendors
chunk automatically that easily when it comes to dynamic imports (import("path")
) since CommonChunkPlugin
doesn't select non-entry chunks..