[英]How to expose an object globally with Browserify?
I've looked online at how to expose a global variable to the window
object in Browserify but to no avail.我在网上查看了如何在 Browserify 中向
window
对象公开全局变量,但无济于事。 All I found was a really dead Stack Overflow question and blogs.我发现的只是一个非常死的 Stack Overflow 问题和博客。 Do I have to do this manually or is there a
config
option for it like Webpack's libraryTarget
option?我必须这样做手工,还是有
config
类似的WebPack的为它选择libraryTarget
选项? I have looked for the answer .我一直在寻找答案。
I found that setting the insertGlobalVars
property on the browserify options works lovely for this.我发现在
insertGlobalVars
选项上设置insertGlobalVars
属性很适合这个。 For anyone else wondering go to对于其他想知道的人,请访问
Defining global variable for Browserify .
为 Browserify 定义全局变量。
There's example code, too.还有示例代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.