如何使用webpack添加jquery插件?

如何使用webpack添加jquery插件?,jquery,angular,webpack,Jquery,Angular,Webpack,我正在使用带有angular 2的webpack作为我的web应用程序,我需要在我的应用程序中添加一个jquery滑块,所以我使用了一个jquery插件 我的jquery网页包配置为 new ProvidePlugin({ jQuery: 'jquery', $: 'jquery', jquery: 'jquery' }) 上面的ProvidePlugin在我的整个应用程序中都提供了$和jQuery,但我还需要将jQuery插件导入到main.ts inc

我正在使用带有angular 2的webpack作为我的web应用程序,我需要在我的应用程序中添加一个jquery滑块,所以我使用了一个jquery插件

我的jquery网页包配置为

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

上面的ProvidePlugin在我的整个应用程序中都提供了$和jQuery,但我还需要将jQuery插件导入到main.ts include中的我的应用程序中

import 'jquery';
一次

然后在网页包配置中

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

通常,jQuery插件会在需要的地方导入,而不是全局导入

例如:

import 'jquery.waterwheelCarousel.min.js';
这将导致加载插件文件,并且由于jQuery是全局提供的,因此它将导致在jQuery对象(
$(“#carousel”).waterheelcarousel()上提供插件函数


如果您想使其在全球范围内可用,请查看“同时导入jquery插件”-您指的是哪个插件?jquery.WaterheelCoursel