Bundling and Minification in ASP.NET MVC 4
This post is part of ASP .NET MVC 4 Article Series.
We have enabled default bundles, but still we have not referenced it in view. Open _Layout.cshtml and looks for following lines in Head tag.
Bundling and Minification with CSS
Same way we can also reference bundled and minified CSS by replacing default CSS reference with following one in _Layout.cshtml. However Bundling and Minification does not works with CSS3 rules. It is also logged here on connect.microsoft.com. I have posted temporary workaround for it here in my post: ASP.NET 4.5 : Issue With CssMinify And Workaround For It
Creating custom Bundle with .NET 4.5 and MVC 4
Bundle myJSBundle = new Bundle("~/MyJSBundle", typeof(JsMinify));
myJSBundle.AddDirectory("~/Scripts", "*.js", false);
To reference created custom bundle, write following lines in respective view.
With vNext or .NET 4.5, it is easier to implement Bundling and Minification with very less effort and without major changes.
Hope this would be helpful.
Check out this index post on ASP.NET Web Optimization Framework (a.k.a Bundling & Minification) to read other post on same.