Use velocity.js with webpack

情到浓时终转凉″ 提交于 2020-01-02 07:06:12

问题


I'm trying to use some parts of materialize-css, js, some of these parts depend on velocity and some other chunks of code that I have depend on jQuery. I'm using webpack to build it all.

requiring velocity is not working for me, I still get a .velocity is not a function. I use ProvidePlugin to inject jQuery (installed with npm) where $ or jQuery are used, and this is working nice.

plugins: [
  new webpack.ProvidePlugin({
    $: "jquery",
    jQuery: "jquery",
  })
]

However looks like velocity is not being able to inject velocity method into jQuery. I've also tried:

module: {
  loaders: [
    {
      test: /jquery\.js$/,
      loader: "expose?jQuery!expose?$"
    }

回答1:


if you look in velocity.js's node module, it uses window.jQuery you should try adding window.jQuery instead to the webpack ProvidePlugin

plugins: [
    new webpack.ProvidePlugin({
        $: "jquery",
        jQuery: "jquery",
        "window.jQuery": "jquery"
    })
]


来源:https://stackoverflow.com/questions/35104732/use-velocity-js-with-webpack

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!