Find file History
Latest commit 829a19c Feb 18, 2016 @davidt davidt Add custom LessCSS compiler.
The built-in Less compiler works fairly well, but has a couple issues that were
annoying me.

First of all, in order to cope with an old bug in lessc that no longer exists,
it redirected the output of lessc rather than passed the output filename on the
command line. This made it impossible to use the `--source-map` argument, which
makes devtools a much nicer experience. I've reimplemented `compile_file` to
pass in the outfile name on the command-line, and raised the question with the
django-pipeline maintainer to see if we can't get that upstream.

Second, the compiler was completely ignoring the outdated check and always
recompiling every file on every load. This made sense because there was no
dependency analysis, so if an `@import`ed file was changed, the dependent file
would not be recompiled. This was slowing down reloads a fair bit (but it was
still faster than recompiling in the browser).

To fix this second part, I've written a helper, `less-imports.js`, which uses
the less module's parser to get a deep list of the file imports. These are then
each compared against the target output file's timestamp to see if anything is
out of date. While this is still some overhead (since it still has to parse
the files), it's quite a bit faster than actually recompiling.

Testing done:
- Loaded and reloaded things a bunch.
- Made a change to defs.less and saw in the log that it was recompiling all the
  files that imported it.

Reviewed at
Failed to load latest commit information.
internal Add custom LessCSS compiler. Feb 23, 2016