Webpack 从捆绑包中排除库
我正在尝试将项目与 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论