imathis/octopress — pull request #648 by BPScott (2012-06-30 17:37:04+00:00)
Title: Add Guard support for watching for file changes

Hi @imathis, here's some thoughts on using Guard for watching compilation. Let me know what you think to this implementation.

When I [initially mentioned](https://github.com/imathis/octopress/commit/c2e14bf88e6e32e16dd83b0d67d4dcb6a169cbee#commitcomment-1468223) my ideas about Guard I claimed we would be able to use existing gems for various compilations. Unfortunately my original optimism was soon dashed as guard-jekyll and guard-uglify didn't quite behave in the way I was hoping (details in the commit msg), so I have had to include bespoke implementations for these compilation steps.

Generating and previewing builds remains the same as before - using the rake generate, watch and preview tasks. Guard will not run a compile when it is first run, only on file changes so you may have to run `rake generate` prior to `rake watch` or `rake preview` to ensure you have the latest output files.

### Potential controversy

To keep this implementation as simple as possible I've had to make two changes that are fair deviations from how octopress currently does things, but I figure it's easier to demo what I've done then gather feedback as part of this PR than debate these ideas up front :)

* I have moved "javascripts" out of the source folder, into the root as this simplifies the deployment process and keeps it inline with the process for sass - a folder in the root compiles to something under /source, which is then copied into /public as part of the Jekyll compile.

* Uglify has replaced JsMin as JavaScript minifier as it produces smaller files and because calling a rake task from within guard, which was originally triggered by a rake task seems a bit convoluted. There is no longer any coffeescript support because of this. If coffeescript support is to be added in the future then I think it makes the most sense to swap out my uglify guard for a dedicated asset compiler such as Sprockets.

### Commit Msg

This commit allows octopress to use Guard as a mechanism for watching the
file system to trigger compilation of SASS, JavaScript and Jekyll assets.
Uglify replaces JSMin as the JS compressor as it is much smarter.

Guards included:
* Compass
* Jekyll (own basic implementation as rubygems version doesn't work, due to
it overriding the configuration in _config.yml)
* Uglify (own basic implementation as rubygems version doesn't allow you to
concatenate multiple files togather)
* LiveReload (https://github.com/guard/guard-livereload)

Default build pipeline is as follows:

* /sass folder is watched and outputs to /source/stylesheets using compass
* /javascripts folder is watched and outputs to /source/javascripts using
uglify
* /source is watched and outputs to public using jekyll
* /public is watched and triggers LiveReload