The Best Hakyll Workflow I've Found

I've been doing some work with Hakyll and Stack, specifically editing the Hakyll site.hs file. Originally I was manually compiling and rebuilding every time I make changes to site.hs, but that was a little awkward, so I came up with a script to make things smoother. Ideally, I want everything to rebuilt when I change site.hs or any of the site's assets. I also want to stop the script with Ctrl-C when I'm done. In the end this is what I came up with...

#!/bin/bash
trap 'kill %1; kill %2;' SIGINT
stack exec site server & \
  ls content/*.* \
     css/*.* images/*.* \
     templates/**/*.* \
     templates/*.* \
     site.hs \
  | entr stack build --exec "stack exec site rebuild"

The trap line will kill the subprocesses on a SIGINT. The first process is the Hakyll server command. The second one is entr, which will watch the files that I pipe into it, and run stack build --exec when there is a change. The --exec is used to run the Hakyll rebuild command, so that the cache gets cleaned whenever a recompile happens or any of the site content changes.

When I'm doing editing site.hs I switch back to the default site watch command since that's faster and more efficient.