In MVC 4 we have bundles. While defining the bundles we can use wildcards like * for all files in a folder.
In the example below what does -{version}
mean?
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
}
The
-{version}
basically maps to a version regex, or to be precise:(\d+(?:\.\d+){1,3})
.Using
*
tends to grab too much, for example if you bundlejquery*
, that will includejquery-ui
as well which might mess up the ordering. But usingjquery-{version}.js
would let you avoid having to update your bundle definition every time you upgrade jquery.Additional things to note:
{version}
only works for the last part of the path--basically the file name--not a directory.This bundle is able to accomodate version numbers in script names. So updating jQuery to a new version in your application (via NuGet or manually) doesn't require any code / markup changes.
See the following link for more information on bundling: http://weblogs.asp.net/jgalloway/archive/2012/08/16/asp-net-4-5-asp-net-mvc-4-asp-net-web-pages-2-and-visual-studio-2012-web-developer-features.aspx