Webpack 从捆绑包中排除库

发布于 2025-01-14 16:47:49 字数 405 浏览 1 评论 0原文

我正在尝试将项目与 webpack 5 捆绑在一起。 动态导入有问题,我无法修复它,所以我决定从捆绑包中排除这个库,然后它就可以正常工作了。 但是,在生产版本中,我删除了 node_modules 因为它在 lambda 上运行。

所以这里有一个问题:我们可以从捆绑包中排除库,但在没有node_modules的情况下使用它吗?如果是,我们如何实现这一点?

例如,将库从 node_modules 复制到 dist 文件夹,然后更改 import * from "library_name " 指向 import * from "./dist/library_name" 目录。

I'm trying to bundle the project with webpack 5.
There is a problem with dynamic import, and I can't fix it, so I decided to exclude this library from the bundle, and then it works fine.
But, In the production version, I'm removing node_modules because it's running on lambda.

So here is a question: Can we exclude library from bundle but use it without node_modules? If yes, how we can achieve this?

For example, copy the library from node_modules to the dist folder and then change import * from "library_name" to point to the import * from "./dist/library_name" directory.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文