我试图用webpack加载jquery-mobile.但到目前为止没有运气.
这是我的jquery和jquery-mobile的webpack.config代码:
loaders: [
{
test: /jquery.mobile.js$/,
loader: "imports?define=>false,this=>window"
},
resolve: {
alias: {
"jquery": "jquery/src/jquery",
"jquery-mobile": "jquery-mobile/dist/jquery.mobile"
},
},
plugins: [
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"window.jQuery": "jquery"
}),
]
Run Code Online (Sandbox Code Playgroud)
这是jquery.mobile文件中的函数,它会导致麻烦:
(function ( root, doc, factory ) {
if ( typeof define === "function" && define.amd ) {
// AMD. Register as an anonymous module.
define( [ "jquery" ], function ( $ ) {
factory( $, root, doc );
return $.mobile;
});
} else {
// Browser globals …Run Code Online (Sandbox Code Playgroud)