While it is nice to have a value computed each time you save a buffer in emacs, setting up the respective command on a per-buffer basis can be tedious—especially, when that mode, with a particular command, should be activated for a whole subtree. Buffers being cleaned up, e.g., by midnight-mode, while convenient, does not reduce the amount of setup necessary either.
Fortunately, there is find-file-hook where you can register tasks to be done after opening a new file—and those tasks can be arbitrary functions that are evaluated with the newly opened file as current buffer. Hence we compare buffer-file-name against an an association list of prefixes (sorted, upon loading, most-specific entry first), take the associated command, if any, assign it to the buffer-local variable and start the buffer build (as background command, as usual).
The correspondingly extended buffbuild.el can be downloaded, with the new part coming after the definition of the minor mode.