问题
Situation
I'm trying to load a library with Webpack. The library itself has been split up using Webpack into multiple chunks.
Project A has a dependency on project B. Project B has been built with Webpack and consists of multiple chunks. Project A now loads project B through a dynamic import. When project A is built, I would like the chunks of project B to be created in the output folder of project A.
Question
How do I get the chunks of project B to persist as chunks in the final build of the project?
Example
I made an example project (https://github.com/Robinfr/chunky-webpack) that has two levels of sub-packages. Both sub-package-a and b create chunks but they are all usurped into a single main-bundle.js when building the main-package.
回答1:
After some experimentation, I figured out that just using the source files as is and only compiling in the final product is one of the ways to go. This way Webpack can generate the chunks for all of the packages.
来源:https://stackoverflow.com/questions/48645670/importing-loading-library-with-chunks