Currently I am testing bundles and I know there is possibility to use wild cards such as {version}
or *
. I am not entirely sure what {version}
is for. I assume *
works like regular expression that takes everything that would match all possibilities: jquery*
means everything like jqueryA
, jquery-ui.js
etc. I would simply like to have possibility to choose either developer or production version of my javascript libraries, css files, etc. Below is the file structure:
Content\
css\
bootstrap-theme.css
bootstrap-theme-min.css
bootstrap.css
bootstrap.min.css
the same with Scripts:
Scripts\
jquery-2.1.3.js
jquery-2.1.3.min.js
jquery-ui.js
jquery-ui.min.js
I have defined the following bundles but I feel like {version}
is wrong at all or at wrong place inside strings:
bundles.Add(new ScriptBundle("~/bundles/jquery").Include("~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include("~/Scripts/jquery-ui{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include("~/Scripts/modernizr-*"));
bundles.Add(new StyleBundle("~/bundles/css/Bootstrap").Include("~/Content/css/bootstrap-theme{version}.css"));
bundles.Add(new StyleBundle("~/bundles/css/Bootstrap").Include("~/Content/css/bootstrap{version}.css"));
bundles.Add(new StyleBundle("~/bundles/css").Include("~/Content/StyleSheet.css"));
How can I instruct ASP.NET to substitute for instance bootstrap.css
over bootstrap.min.css
in release version of application.
Thanks!
The {version}
is somewhat like a wildcard, but it does two extra things, it restricts the wildcard to something that looks like a version number ("1.2.3", for example) and it uses the highest version it finds. This allows you to have multiple versions of the same script and the bundler will always use the latest.
For example, if you had the following:
Scripts\
+ jquery-1.10.1.js
+ jquery-1.10.2.js
+ jquery-2.0.0.js
And a script bundle like:
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js");
Then, ~/Scripts/jquery-2.0.0.js
would be added to the bundle.