Single-file-output LESS compiler for Broccoli


The broccoli-less-single plugin compiles .less files with less.js.

This plugin is designed to compile a single, primary input file into a single output file, with a tree of @importd dependencies. This differs from broccoli-less, which compiles each .less file individually into a .css file and doesn't support @imports or a single output file depending on multiple inputs.

This code is based heavily on broccoli-sass

npm install --save-dev broccoli-less-single
var compileLess = require('broccoli-less-single');
var outputTree = compileLess(inputTrees, inputFile, outputFile, options)
  • inputTrees: An array of trees that act as the include paths for less. If you have a single tree, pass [tree].

  • inputFile: Relative path of the main .less file to compile. This file must exist in one of the inputTrees.

  • outputFile: Relative path of the output CSS file.

  • options: A hash of options for less.

var appCss = compileLess(sourceTrees, 'myapp/app.less', 'assets/app.css')
/* file: sub.less */
h1 {
  font-size: 200em;
/* =================== */
/* file: app.less */
@import "sub.less";
htmlbody {
  margin: 20px;