I want to be able to minify/bundle my javascript files in a production environment while having them unminified/unbundled when debugging locally; however, the default WebForms site in VS2012 does not appear to allow for it.
Steps to reproduce my issue:
- Create a new "ASP.NET Web Forms Application" (c# in my case)
- Start without debugging and view resources in browser
- Notice unminified jquery/modernizr files but bundled/minified
MsAjaxJS
andWebFormsJs
web.config, by default has:
<compilation debug="true" targetFramework="4.5">
And I've even tried modifying the Global.asax by explicitly telling BundleTable
not to optimize:
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
BundleTable.EnableOptimizations = false;
BundleConfig.RegisterBundles(BundleTable.Bundles);
AuthConfig.RegisterOpenAuth();
RouteConfig.RegisterRoutes(RouteTable.Routes);
}
Yet, I still get undebuggable javascript files:
This site (which I realize is for MVC) tells me that either debug="true"
in the web.config or BundleTable.EnableOptimizations = false;
in Global.asax should turn off the functionality. And this site, (which is for WebForms and is linked from the first), doesn't mention turning it off for debugging.
How might I (cleanly) tell my project to only minify/bundle when debug="false"?
(I'm using ASP.NET 4.5)
EDIT:
This question and this question are similar, but they both only offer a solution using Scripts.Render()
. Is there a way to accomplish this with the templated method of using the ScriptManager?