Support lessc include paths and global variables in extension packaging.

Review Request #4986 — Created Nov. 17, 2013 and submitted




Support lessc include paths and global variables in extension packaging.

This improves extension packaging by allowing .less files to include
files relative to one of the registered static directories, and to make
use of global variables.

When building a .less file, Djblets will calculate all the main static
media directories provided by the parent project and by the extension
and add them to the less import search path. This allows an extension
to, do, say:

@import "myapp/css/defs.less";

It also makes use of the new global variable support in LessCSS 1.5.1
to pre-define variables for .less files. BuildStaticFiles subclasses can
override get_lessc_global_vars to define the global variables available
to a .less file.

This can be used to standardize search paths in a way that works during
both runtime (using less.js) and compile time (with lessc), since those
two modes otherwise have very different search paths. For example:

@import "@{DEFS_PATH}/mixins.css";

It can also be used to define variables used for LessCSS guards, to
separate rules for runtime vs. packaging.

Tested an extension in Review Board that imported our defs.less file
using a global variable, and defining that variable to a URL in a template
for less.js, and a location in a search path for packaging (in the
custom BuildStaticFiles command).

I was able to successfully make use of definitions in both cases.

Verified in the generated .css files that the definitions were used,
and no imports remained.

  1. Ship It!
Review request changed

Status: Closed (submitted)