Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Bundling and Minification - Including Already Minified Files for Production Bundles and Unminified Files for Development

Tags:

I want some expert advice on ASP.NET MVC Bundling and Minification. I have in my project script files that have both unminified (.js) and minified versions (.min.js). I have included them in my script bundle as follows:

bundles.Add(new ScriptBundle("~/bundles/layout").Include(
                    "~/Scripts/jquery-{version}.js",
                    "~/Scripts/lib/errorhandling.js",
                    "~/Scripts/lib/errorhandling.min.js",
                    "~/Scripts/vendor/modernizr.custom.js",
                    "~/Scripts/vendor/modernizr.custom.min.js",
                    "~/Scripts/toastr.js",
                    "~/Scripts/toastr.min.js"));

It seems that the bundle indeed contains only once each script file, not twice. I have confirmed this both for development and production. (As a side note, in development, that is, when debug=true, the bundles are not rendered but the files are included as separate script tags. This is the desired behaviour for me, as well.)

My questions are:

(1) Is this the best and recommended way to include already minified files for production setup and unminified files for development?

(2) Does ASP.NET try to minify the whole bundle in production (even though it is already minified)? If yes, what is the best way to prevent ASP.NET from trying to minify the bundle?

Thanks in advance!