Is it possible to include one bundle in another bundle in ASP.NET MVC?
I would like to do something like:
bundles.Add(new ScriptBundle("~/bundles/jquery").Include("~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jquery-ui").Include("~/Scripts/jquery-ui-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include("~/Scripts/jquery.validate*"));
bundles.Add(new ScriptBundle("~/bundles/knockout").Include("~/Scripts/knockout-{version}.js").Include("~/Scripts/knockout.ext.js"));
bundles.Add(
new ScriptBundle("~/bundles/ui")
.Include("~/bundles/jquery")
.Include("~/bundles/jquery-ui")
.Include("~/bundles/jqueryval")
.Include("~/bundles/knockout")
);
You can define the common parts in a string array
string[] jQuery = new string[] { "~/Scripts/jquery-{version}.js",
"~/Scripts/jquery-ui-{version}.js" };
Then reuse it like this
bundles.Add(new ScriptBundle("~/bundles/jQuery")
.Include(jQuery));
bundles.Add(new ScriptBundle("~/bundles/jQueryVal")
.Include(jQuery)
.Include("~/Scripts/jquery.validate*"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With