Managing jQuery plugin dependency in webpack

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

    The best solution I've found was:

    https://github.com/angular/angular-cli/issues/5139#issuecomment-283634059

    Basically, you need to include a dummy variable on typings.d.ts, remove any "import * as $ from 'jquery" from your code, and then manually add a tag to jQuery script to your SPA html. This way, webpack won't be in your way, and you should be able to access the same global jQuery variable in all your scripts.

提交回复
热议问题