问题
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