Trigger build when certain files are saved

Is there an easy way of triggering a build when certain CSS/JS files change? I basically need the combined functionality of compass watch and https://github.com/pferdefleisch/guard-sprockets. I suppose the Listen gem could be used somehow.

You could do something like this:

files.changed /\.css$/ do |file|
  `middleman build --glob #{file}`
end

The first regex picks what changes the block gets called for. Then the build command takes a “glob” to build a subset of files.

Hopefully in v4 we’ll have direct Ruby access to the builder so it won’t need to “shell out” to middleman

Awesome, thanks a lot!