导出 webpack bundle/prepend module.exports?避免节点中的空对象? [英] Export a webpack bundle / prepend module.exports? Avoid empty object in node?
本文介绍了导出 webpack bundle/prepend module.exports?避免节点中的空对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将我的 bundle.js 引入我的 Node 服务器,但显然 webpack 包在顶部的所有包代码之前缺少 module.exports =
.
I'm trying to require my bundle.js into my Node server, but apparently the webpack bundle is missing a module.exports =
before all of the bundle code at the top.
我可以手动将 module.exports =
放入这个包中,但是必须有一种编程方式来指定包应该是可导出的
I can manually put module.exports =
into this bundle, but there has to a programmatic way to specify the bundle should be exportable
推荐答案
您是否尝试添加
libraryTarget: 'umd'
到 webpack 配置.看看这个.
to the webpack config. Have a look at this.
这篇关于导出 webpack bundle/prepend module.exports?避免节点中的空对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文