M
M
Maxim Medvedev2020-05-08 09:01:20
JavaScript
Maxim Medvedev, 2020-05-08 09:01:20

How to load variables globally in webpack?

Good afternoon.
There is an old project in which the assembly works on gulp.js. Everything worked, but I decided to rewrite it on webpack. The problem is the following, there is a util.js file in which the content is something like this:

var init_refresh_script = function () {

},
var init_script = function () {

},
App = function () {
  	return {
      init: function () {
      	init_script(),
     },
  }
}();

$(function () {
App.init();
});


In the right places in the project, init_refresh_script () and the like are used to reload or hang events on the created elements. The problem is that webpack loads all the contents of the above file into the module and somewhere on the project page I can’t write init_refresh_script () now, because I get "Uncaught ReferenceError: init_form is not defined". How to fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2020-05-08
@alexey-m-ukolov

window.init_refresh_script = function () {

}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question