Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC 4 is bundling js files in Debug Mode

"The issue is that, by default, asp.net mvc DOES NOT bundle the css and js files in debug mode. But our css and js files ARE getting bundled in the debug mode."

For some reason, all the css and js files are being bundled in debug mode. It started few days ago. We have a large team with several developers and its hard to find out what changed in the last few days because there are several changes submitted to the repository. However I didn't find any significant changes in the BundleConfig and Global.asax.cs.

When the application is running in debug mode, BundleTable.EnableOptimizations returns a false.

To my understanding when debug is set to true then bundling does not happen. <compilation debug="true" targetFramework="4.5">

So far I haven't found a single occurrence of this issue on Google. Is this a very unique problem?

Ideally instead of a workaround I would like to fix it. Finding the cause is the actual problem here. Any pointers on where I should start looking for the fix would be appreciated. Thank you.

Edit: My question is similar to but not exactly the same as ASP.NET MVC 4 app with bundling and minification, why is minification enabled in debug mode? Someone please remove the "This question may already have an answer here:" tag. In my case the bundle paths are already starting with a "~"

Template: @Styles.Render("~/Content/css") @Scripts.Render("~/bundles/js")

Bundle Config: bundles.Add(new Bundle("~/Content/css").Include("~/Content/*.css")); bundles.Add(new Bundle("~/bundles/js").Include("~/Scripts/myproj.*"));

like image 717
Oxon Avatar asked May 30 '13 10:05

Oxon


1 Answers

Try adding this in your global Application_Start()

BundleTable.EnableOptimizations = false;

So...

protected void Application_Start()
{
     AreaRegistration.RegisterAllAreas();
     WebApiConfig.Register(GlobalConfiguration.Configuration);
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     AuthConfig.RegisterAuth();

     BundleTable.EnableOptimizations = false;
}
like image 110
Gabe Avatar answered Nov 14 '22 22:11

Gabe