小编Bus*_*eBu的帖子

使jQuery-Mobile与webpack一起工作

我试图用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)

jquery jquery-mobile webpack

6
推荐指数
1
解决办法
2726
查看次数

标签 统计

jquery ×1

jquery-mobile ×1

webpack ×1