Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically compress html and css on Publish?

I can't find a decent answer to this question. I see there are a couple other similar questions that have been asked, but they do not provide me with decent answers.

In Visual Studio, is there a way to compress all files that should be compressed (HTML, XML, CSS) automatically when the application is published?

It seems a bit pointless and wasteful to have all the extra white space, comments, and other things on the server. I have looked for different Extensions and NuGet packages, but have been unable to find anything that provides me with a solution.

like image 645
Blanky Avatar asked Jul 13 '12 00:07

Blanky


1 Answers

You want something like Cassette.

Cassette automatically sorts, concatenates, minifies, caches and versions all your JavaScript, CoffeeScript, CSS, LESS, Sass and HTML templates.

It's very simple to use, just read their documentation. It takes at most 5 minutes to setup.

To install, open the NuGet Package Console and type in:

Install-Package Cassette.Web

This will take care of installing, and setting things up for you.

For help or suggestion, check out their Google Group:

http://groups.google.com/group/cassette


There is also the option of using SquishIt. It works fine with MVC3 and serves the same purpose as Cassette. However, personally I prefer Cassette.

http://lostinthegc.wordpress.com/2012/01/14/using-squishit-in-an-asp-net-mvc3-web-application/

like image 155
Only Bolivian Here Avatar answered Oct 20 '22 20:10

Only Bolivian Here