title: RequireJS - ASP.NET MVC Bundle Script
body: <p>I have two questions.</p>
  
  <p>I am trying to learn RequireJS and use it along with ASP.NET MVC bundling &amp; minification. I am using a separate config file for RequireJS which holds the bundling information. My first problem is how do I pass on the bundle path generated by MVC to the require.config.js file. A clean way to do that will be as below:</p>
  
  <p>index.cshtml</p>
  
  <pre><code>&lt;script id="requirescript" type="text/javascript" src="~/Scripts/require.config.js"
      data-baseurl="@Url.Content("~/Scripts")"
      data-bundlepath="@System.Web.Optimization.Scripts.Url("~/bundles/scripts").ToString()"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>require.config.js</p>
  
  <pre><code>var reqScript = document.getElementById('requirescript');
  var baseUrl = reqScript.getAttribute('data-baseurl');
  var bundlePath = reqScript.getAttribute('data-bundlepath');
  var require = {
      baseUrl: baseUrl,
      bundles: {
        bundlePath : ['jquery','jqueryui','mymodule']
      }
    }
  };
  </code></pre>
  
  <p>When I do the above, RequireJS tries to load a non-existing script named bundlePath.js, instead what I want is to load the bundled script which is '/bundles/scripts?v=GZ0QWPB4G0soItEmlsPC6Yp3zftCRVleVTcH3LseMWo1' which contains my modules. So first, my question is how do I pass the bundle URL, as generated by the server, to RequireJS in the require.config.js file without hard-coding the bundle path?</p>
  
  <p>Secondly, the jqueryui module seems to be not loading. I have added the module name in the AMD code in jquery ui min file. How do I make jquery ui work with RequireJS and ASP.NET bundling?</p>