将Velocity.js与Webpack一起使用 [英] Use velocity.js with webpack
问题描述
我试图使用materialize-css
,js
的某些部分,其中一些部分取决于速度,而我依赖于jQuery
的其他一些代码块.我正在使用webpack
来构建所有内容.
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.
要求速度对我不起作用,我仍然得到.velocity is not a function
.我使用ProvidePlugin
注入jQuery(随npm安装),其中使用了$
或jQuery
,并且效果很好.
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",
})
]
但是,看来速度无法将velocity
方法注入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?$"
}
推荐答案
如果查看Velocity.js的节点模块,它将使用window.jQuery
您应该尝试将window.jQuery
代替添加到webpack ProvidePlugin
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"
})
]
这篇关于将Velocity.js与Webpack一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!