Is it possible to include one bundle in another bundle in ASP.NET MVC?
是否可以在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")
);
1 个解决方案
#1
12
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*"));
#1
12
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*"));