Search code examples
asp.netvisual-studioasp.net-mvc-4asp.net-optimization

Visual Studio and Knockout.js - Bundling, minification and convention


I'm using bundling and minification with ASP.NET MVC4 and Visual Studio.

The convention says that:

  • Selecting “.min” file for release when “FileX.min.js” and “FileX.js” exist.
  • Selecting the non “.min” version for debug.
  • Ignoring “-vsdoc” files (such as jquery-1.6.2-vsdoc.js), which are used only by IntelliSense.

The problem is that also debug.js extension are completely ignored and when I'm using knockout and knockout mapping via NuGet those come with these extensions. So I always get the minified version even if in debug mode?

I could rename the files from .debug.js to .min.js to get the non minified version in debug mode but wouldn't that break the update function via nuget?

Is there a solution for .debug.js files?


Solution

  • Here's the full current ignore list default conventions as of RTM 1.0:

            ignoreList.Ignore("*.intellisense.js");
            ignoreList.Ignore("*-vsdoc.js");
            ignoreList.Ignore("*.debug.js", OptimizationMode.WhenEnabled);
            ignoreList.Ignore("*.min.js", OptimizationMode.WhenDisabled);
            ignoreList.Ignore("*.min.css", OptimizationMode.WhenDisabled);
    

    So debug.js will be ignored when debug=false. Renaming or clearing the ignore list are the two easy workarounds.