Reputation: 9080
My BundleConfig.cs
file looks like this (CSS):
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/site.css",
"~/Content/bootstrap-switch.css",
"~/Content/datepicker.css",
"~/Content/bootstrap-duallistbox.css",
"~/Content/fullcalender.css",
"~/Content/fullcalender.print.css"));
BundleTable.EnableOptimizations = true;
No where am I calling bootstrap.min.css, however, when I updated only the bootstrap.css file none of my changes were recognized. I started to make the changes in the .min file and then I noticed my changes.
I get that the BundleTable.EnableOptimizations = true;
takes all of the .css files and minimizes them, but I don't understand why I had to update the .min file for it to recognize my style changes.
I expected the bootstrap.css
file to be minimized in memory and used that way.
Can someone explain why this is occurring?
Just for more information I'm using MVC5 in VS2013
Upvotes: 1
Views: 4818
Reputation: 47375
When you include stylesheet.css
in an bundle and there is already a stylesheet.min.css
file in your project, the optimization framework will use the .min
file when BundleTable.EnableOptimizations == true
.
It does the same thing for script.min.js
files.
BundleTable.EnableOptimizations = true; // when this is not false
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css", // will look for bootstrap.min.css
"~/Content/site.css", // will look for site.min.css
"~/Content/bootstrap-switch.css", // will look for bootstrap-switch.min.css
"~/Content/datepicker.css", // will look for datepicker.min.css
"~/Content/bootstrap-duallistbox.css", // will look for bootstrap-duallistbox.min.css
"~/Content/fullcalender.css", // will look for fullcalender.min.css
"~/Content/fullcalender.print.css")); // will look for fullcalender.print.min.css
If you would rather have the optimization framework minify for you, just remove bootstrap.min.css from your project.
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
// Code removed for clarity.
}
The preceding code creates a new JavaScript bundle named ~/bundles/jquery that includes all the appropriate (that is debug or minified but not .vsdoc) files in the Scripts folder that match the wild card string "~/Scripts/jquery-{version}.js". For ASP.NET MVC 4, this means with a debug configuration, the file jquery-1.7.1.js will be added to the bundle. In a release configuration, jquery-1.7.1.min.js will be added. The bundling framework follows several common conventions such as:
Upvotes: 2