导入/加载带有库的库 [英] Importing/loading library with chunks

查看:209
本文介绍了导入/加载带有库的库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

情况

我正在尝试使用Webpack加载库。库本身已使用Webpack拆分为多个块。

I'm trying to load a library with Webpack. The library itself has been split up using Webpack into multiple chunks.

项目A对项目B有依赖性。项目B是使用Webpack构建的,并且由多个块组成。现在,项目A通过动态导入加载项目B。构建项目A后,我希望在项目A的输出文件夹中创建项目B的大部分内容。

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.

问题

如何使项目B的块作为块保留在项目的最终版本中?

How do I get the chunks of project B to persist as chunks in the final build of the project?

示例

我创建了一个示例项目( https://github.com/Robinfr/chunky-webpack ),它具有两个子包级别。子软件包a和b都创建了块,但是在构建主软件包时,它们都被篡改成一个main-bundle.js。

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.

推荐答案

经过一些试验,我发现仅使用源文件并且仅在最终产品中进行编译是可行的方法之一。这样Webpack可以为所有软件包生成块。

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.

这篇关于导入/加载带有库的库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆