I am just trying out ASP.NET MVC 4 but I can\'t figure out how to disable Javascript/CSS minification feature. Especially for development environment this will help greatly
You could register your own bundles in the Global.asax and use the NoTransform
class if you do not want the content to be minified.
I personally don't want my script to be transformed at all. I just create two script directories. One with the debug script versions and one with the originally downloaded minified versions.
The MVC 4 out of the box minifier (JsMinify) breaks jQuery 1.7.1 for Opera, so I do not want to use that one. I just put the following lines in my Global.asax: Application_Start()
method:
Bundle debugScripts = new Bundle("~/DebugScripts",
new NoTransform("text/javascript"));
debugScripts.AddDirectory("~/Scripts/Debug", "*.js");
BundleTable.Bundles.Add(debugScripts);
Bundle productionScripts = new Bundle("~/ProductionScripts",
new NoTransform("text/javascript"));
productionScripts.AddDirectory("~/Scripts/Minified", "*.js");
BundleTable.Bundles.Add(productionScripts);
With that in place I can simply add either one of two lines in my _layouts.cshtml
:
Of course we could get a little more funky with this in place. We could generate just one bundle and depending on the built type select what files to include.