Managing jQuery plugin dependency in webpack

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

    Edit: Sometimes you want to use webpack simply as a module bundler for a simple web project - to keep your own code organized. The following solution is for those who just want an external library to work as expected inside their modules - without using a lot of time diving into webpack setups. (Edited after -1)

    Quick and simple (es6) solution if you’re still struggling or want to avoid externals config / additional webpack plugin config:

    
    
    
    
    

    inside a module:

    const { jQuery: $, Underscore: _, etc } = window;
    

提交回复
热议问题