Search code examples
asp.net-mvc-3bundling-and-minification

Bundling debug or release scripts automatically


Using ASP.NET MVC3 I am bundling & minifying my React scripts. This is working fine but I am wondering if I can include certain files and exclude others automatically by naming them correctly. I can't seem to find any documentation around this. Here's what I have at the moment in my BundleConfig.cs file:

bundles.Add(new ScriptBundle("~/bundles/react")
    .Include(    
        #if DEBUG
            "~/Scripts/react.debug.js",
            "~/Scripts/react-dom.debug.js",
        #else
            "~/Scripts/react.production.min.js",
            "~/Scripts/react-dom.production.min.js",
        #endif
));

From what I understand, the bundling & minifcation process ignores .min files. Does it have any other rules around .release or .debug files? I've done some initial testing and I believe it still included the .debug file (hard to tell when it's all being minified.


Solution

  • I've done some testing and can't seem to get bundling & minification to do this automatically, so I don't think it's possible to remove this logic.