[英]ERROR in jQuery is not defined webpack and imports-loader
I got this error when I tried to add a jquery library. 尝试添加jquery库时出现此错误。
{
test: require("path").resolve("./main/static/src/application.js"),
loader: 'imports-loader?this=>window,$=jquery!./main/static/src/vendor/jquery-ui/ui/widgets/draggable.js'
}
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
'window.jQuery': 'jquery',
'window.$': 'jquery',
io: 'socket.io-client',
_:'underscore',
moment:"moment",
})
ERROR: 错误:
ERROR in jQuery is not defined
It looks like there are a few ways to resolve this, I opted for the expose-loader : 看来有几种方法可以解决此问题,我选择了暴露加载器 :
{
test: require.resolve('jquery'),
use: [
'expose-loader?jQuery',
'expose-loader?$'
]
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.