scd
scd copied to clipboard
Add caching to Less compilation
One of the general principles to be followed in this project, is to avoid caches wherever possible. They're difficult to invalidate, and tend to be bug farms.
But, sometimes you can't avoid caching. Right now, Less compilation is the bottleneck in a compilation. While all other work takes 300-400ms on a MacBook Pro, compiling styles-m.less and styles-l.less takes 3+ seconds.
Luckily for us, the Less compiler returns a list of all files used in a compilation (mainly through the @import rule). For local development, where we can (mostly) trust the last-modified time on a file, we should build a cache key of each less file and its last-modified time during compilation. We can then skip compilations on future builds when no dependencies have changed.
Worth noting this would probably only be useful for local dev - can't rely on cache keys that used last-modified for CI, since the file copy will invalidate any last-modified timestamps.