Monday, April 27, 2015

Precompile your LESS and Sass files like a pro

If you've been coding CSS using LESS or Sass for any length of time, you know what a chore it can be to make sure your code gets updated and viewable correctly.  Plus you either have to sacrifice speed in order to compile your css on the fly in your site code, or you have to run a complie process manually before you refresh a browser view of your site to see your changes.  Wouldn't it be great if you made a change to your LESS/Sass code and your browser updated automatically reflecting your change?  Wouldn't that make your feedback loop so much quicker that you'd be able to investigate new and better options?
Because of the complexity of building today's web applications, we're beginning to see a new class of developer application; preprocessors.  Preprocessors take some of the pain away from the manual compilation that needs to occur with things like Less, Sass and even javascript.  They site on a developers workstation and watch for changes to source files that have been designated as needing a compilation process.  Then, as changes are detected, they kick off the appropriate compiler and create the resulting files in your code.  Additionally, through the use of lightweight html proxy servers built in, they can refresh a web page that you are working on whenever the compile process is done (or even more frequently in some cases).
Here are the two that I've been working with, CodeKit for about a year, and Prepros for about a month.  While CodeKit just has a more solid feel to me (it is a bit more mature), Prepros does nearly the exact same job with the benefit of being available on windows for those so accursed (just kidding).  Unfortunately, neither are free, but they are quite reasonably priced with appropriate trials.
CodeKit (for mac)
PrePros (for mac and windows)