title: making jQuery-Mobile work with webpack
body: <p>I was trying to load jquery-mobile with webpack. But no luck so far.</p>
  
  <p>This is my webpack.config code for jquery &amp; jquery-mobile: </p>
  
  <pre><code>loaders: [
      {
          test: /jquery.mobile.js$/,
          loader: "imports?define=&gt;false,this=&gt;window"
      },
  
  resolve: {
      alias: {
          "jquery": "jquery/src/jquery",
          "jquery-mobile": "jquery-mobile/dist/jquery.mobile"
      },
  },
  
  plugins: [
      new webpack.ProvidePlugin({
         $: "jquery",
         jQuery: "jquery",
         "window.jQuery": "jquery"
      }),
  ]
  </code></pre>
  
  <p>And this is the function in jquery.mobile file which causes trouble:</p>
  
  <pre><code>(function ( root, doc, factory ) {
      if ( typeof define === "function" &amp;&amp; define.amd ) {
          // AMD. Register as an anonymous module.
          define( [ "jquery" ], function ( $ ) {
              factory( $, root, doc );
              return $.mobile;
          });
      } else {
          // Browser globals
          factory( root.jQuery, root, doc );
      }
  }( this, document, function ( jQuery, window, document, undefined ) {
  (function( $ ) {
      $.mobile = {};
  }( jQuery ));
  </code></pre>
  
  <p>The problem is that root.jQuery is undefined. Inside that function "this" === "window", as i inject this=>window with imports-loader, i checked that.</p>
  
  <p>And another strange moment: if i replace "this" with "window" like that: </p>
  
  <pre><code>}( window, document, function ( jQuery, window, document, undefined ) {
  </code></pre>
  
  <p>everything becomes fine. But i can't modify jquery.mobile file, this might cause trouble in the future.</p>
  
  <p>Any help would be much appreciated, thank you!</p>