Importing/loading library with chunks

回眸只為那壹抹淺笑 提交于 2020-01-21 06:37:22

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!