There are a couple of things I am puzzled about.
I have been delving into learning RequireJS and employing it in tandem with ASP.NET MVC bundling & minification. I have set up a separate configuration file for RequireJS which contains the bundling details. The primary issue I am facing is how can I transmit the bundle path produced by MVC to the require.config.js file in an efficient manner. Ideally, I would like to implement it as follows:
index.cshtml
<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()"></script>
require.config.js
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']
}
}
};
In the scenario described above, when I execute the code, RequireJS endeavors to load a script named bundlePath.js that doesn't exist. Instead, what I aim for is to fetch the bundled script located at '/bundles/scripts?v=GZ0QWPB4G0soItEmlsPC6Yp3zftCRVleVTcH3LseMWo1' which includes my modules. So, first and foremost, my query is how can I relay the dynamically-generated bundle URL from the server to RequireJS within the require.config.js file without explicitly specifying the bundle path?
Moreover, I seem to be encountering difficulties with loading the jqueryui module. Even though I have included the module name in the AMD code in the jQuery UI minified file. How can I ensure that jQuery UI functions smoothly with RequireJS and ASP.NET bundling?