Search code examples
javascriptnode.jsbrowserify

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. All I found was a really dead Stack Overflow question and blogs. Do I have to do this manually or is there a config option for it like Webpack's libraryTarget option? I have looked for the answer.


Solution

  • I found that setting the insertGlobalVars property on the browserify options works lovely for this. For anyone else wondering go to

    Defining global variable for Browserify.

    There's example code, too.