How to make webpack require work like script tag

时间:2016-07-11 21:52:35

标签: javascript webpack amd commonjs

So I have some JS libs I want to use at global scope (window). They are built with webpack I assume, where their dist code has something like module.exports=xxx If I put them as <script></script> tag in html, I can access them there. But If I require them in webpack, then bundle them with webpack, I cannot see them in global scope.

Is there anything I can do to make them visible without modifying the library itself?

1 个答案:

答案 0 :(得分:0)

你可以试试script-loader,这很简单。代码将在全球范围内执行。