Anyone know of a good technique that minify and combine CSS files from an ASP.NET App_Themes folder before including them in the page?
5 Answers
I always use StyleManager to combine and minify my CSS. It uses a .NET port of YUI Compressor under-the-hood, and adds the ability to combine stylesheets too, so it should do exactly what you need by the sounds of it.
It also adds some nice features like CSS constants, tilde (~) resolution in background-image urls, cache control, etc.
Comments
Rejuicer is a great new minifier for ASP.NET that's getting a lot of buzz: http://rejuice.me
It:
- Has a fluent interface for configuration
- Allows you to specify files to minify with wildcard rules
- Runs on Windows Azure
- Somewhat magically turns itself off in development environments, so you can debug your original javascript code (not minified).
The configuration (done on ApplicationStart in global.asax.cs) is as simple as:
OnRequest.ForJs("~/Combined.js")
.Compact
.FilesIn("~/Scripts/")
.Matching("*.js")
.Configure();
Comments
Also check out RequestReduce. It combines and minifies CSS on the fly and next week's release will include javascript. It also will sprite background images as well as optimize the compresion and color palette of the images. It manages ETAG and expires headers as well. It is compatible with any IIS based web site and requires no code changes or asset reorganization. It requires little to no configuration in basic environments and also provides support for web farms and CDNs. It's OSS (Free) and is currently used on some Microsoft web sites like the Visual Studio Gallery.
Comments
It looks like someone worked on a similar problem here.