Import webpack loader in window.variable

I am working on a project with jQuery and Angular. In particular, it relies on Angular loading with window.jQuery to replace jqLite. Here's the corresponding line of the Angular library:

jQuery = isUndefined(jqName) ? window.jQuery

https://github.com/angular/angular.js/blob/master/src/Angular.js#L1705

My configuration for Angular looks like this:

loader: "imports-loader?jQuery=jquery,this=>window"

However, it seems thisundefined in this particular area:

> console.log(this)
undefined

I also tried this, but it is causing a parsing error on .in webpack.

loader: "imports-loader?window.jQuery=jquery"
+4
source share
1 answer

Here is the configuration I found that ended up working for me:

plugins: [
    new webpack.ProvidePlugin({
        "window.jQuery": "jquery"
    })
]

: https://github.com/webpack/webpack/issues/542

+1

Source: https://habr.com/ru/post/1625941/


All Articles