Managing jQuery plugin dependency in webpack

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

    This works in webpack 3:

    in the webpack.config.babel.js file:

    resolve: {
        alias: {
             jquery: "jquery/src/jquery"
        },
     ....
    }
    

    And use ProvidePlugin

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

提交回复
热议问题