Web Essentials
You can enable this tool using the Extensions And Updates from the TOOLS menu.
- First, right-click on the css file and from the Web Essentials context menu choose to Minify CSS Files. This will ensure that with every build it will generate the accompanying .min.css file too.
- Make sure you have the Web.Release.config beside your web.config
- In your .aspx or .master file put an if statement to figure out if this is running on your debug mode or release mode:
. <% if (HttpContext.Current.IsDebuggingEnabled) { %> <link href="/css/MyFile.css" rel="stylesheet" type="text/css"></link> <%} else {%> <link href="/css/MyFile.min.css" rel="stylesheet" type="text/css"></link> <%} %> .