Managing jQuery plugin dependency in webpack

前端 未结 11 1432
陌清茗
陌清茗 2020-11-22 01:17

I\'m using Webpack in my application, in which I create two entry points - bundle.js for all my JavaScript files/codes, and vendors.js for all libraries like jQuery and Reac

11条回答
  •  滥情空心
    2020-11-22 01:34

    I don't know if I understand very well what you are trying to do, but I had to use jQuery plugins that required jQuery to be in the global context (window) and I put the following in my entry.js:

    var $ = require('jquery');
    window.jQuery = $;
    window.$ = $;
    

    The I just have to require wherever i want the jqueryplugin.min.js and window.$ is extended with the plugin as expected.

提交回复
热议问题