Define global variable with webpack

后端 未结 5 1736
臣服心动
臣服心动 2020-11-22 11:16

Is it possible to define a global variable with webpack to result something like this:

var myvar = {};

All of the examples I saw were using

5条回答
  •  臣服心动
    2020-11-22 11:57

    I solved this issue by setting the global variables as a static properties on the classes to which they are most relevant. In ES5 it looks like this:

    var Foo = function(){...};
    Foo.globalVar = {};
    

提交回复
热议问题