Managing jQuery plugin dependency in webpack

前端 未结 11 1222
陌清茗
陌清茗 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:31

    This works for me on the webpack.config.js

        new webpack.ProvidePlugin({
            $: 'jquery',
            jQuery: 'jquery',
            'window.jQuery': 'jquery'
        }),
    

    in another javascript or into HTML add:

    global.jQuery = require('jquery');
    

提交回复
热议问题