Search code examples
asp.netasp.net-mvcasp.net-mvc-4asp.net-optimization

How to add .min and .debug files in a bundle effectively


I want to take advantage of .min and .debug versions of js and css files.

Consider this bundle for example:

 bundles.Add(
          new ScriptBundle("~/scripts/vendor")
            .Include("~/scripts/jquery-{version}.js")
            .Include("~/scripts/knockout-{version}.debug.js")
            .Include("~/scripts/knockout-{version}.min.js")
            .Include("~/scripts/knockout-{version}.js")

What is the correct mechanism to take advantage of each file. I mean how set some setting to make ASP.NET smart enough to use .min on final releases and .debug while debugging?


Solution

  • Just use .Include("~/scripts/knockout-{version}.js") and ASP.NET will use ~/scripts/knockout-{version}.min.js in production and ~/scripts/knockout-{version}.js when debugging