broccoli-less-single

raw JSON →
2.0.1 verified Fri May 01 auth: no javascript maintenance

A Broccoli plugin that compiles a single primary LESS input file into a single CSS output file, handling @import dependencies. Current stable version is 2.0.1 (last release February 2017). It uses less.js under the hood and focuses on single-file output, unlike broccoli-less which compiles each LESS file individually. Key differentiator: supports imports and produces one output CSS file from multiple input files via LESS imports. The plugin is in maintenance mode with no recent updates.

error Error: The 'broccoli-less-single' plugin does not exist. Did you mean 'broccoli-less'?
cause Typo or confusion with similar package name 'broccoli-less'.
fix
Ensure you have installed 'broccoli-less-single' and require it correctly: const compileLess = require('broccoli-less-single');
error TypeError: compileLess is not a function
cause Using ESM import incorrectly or forgetting to call require.
fix
Use const compileLess = require('broccoli-less-single');
error Error: inputNodes must be an array
cause Passing a single node object instead of an array.
fix
Wrap the node in an array: compileLess([node], ...)
breaking In version 0.5.0, the options hash passed to compileLess is now cloned to avoid mutation of the original object. If you relied on the hash being mutated, your code may break.
fix Do not rely on side effects on the options object; pass a fresh object each time.
deprecated The plugin is no longer actively maintained. Last release was in 2017. Consider migrating to a modern alternative like 'broccoli-less' or 'webpack' with LESS loader.
fix Use alternative solutions that are actively maintained.
gotcha The package does not support ESM imports natively. Attempting 'import compileLess from ...' may fail in Node.js versions that strictly require ESM.
fix Use require() or dynamic import.
gotcha The 'inputNodes' must be an array even if you have only one node. Passing a single node object will cause an error.
fix Wrap a single node in an array: compileLess([node], ...).
gotcha Output file path must be relative and will be created relative to the Broccoli output tree. Absolute paths will not work.
fix Use relative paths like 'assets/app.css'.
npm install broccoli-less-single
yarn add broccoli-less-single
pnpm add broccoli-less-single

Shows how to use broccoli-less-single with broccoli-funnel and broccoli-merge-trees to compile a single LESS file to CSS with caching.

const Funnel = require('broccoli-funnel');
const compileLess = require('broccoli-less-single');
const mergeTrees = require('broccoli-merge-trees');

const appTree = new Funnel('app', { destDir: '.' });
const lessTree = compileLess(
  [appTree],
  'styles/app.less',
  'assets/app.css',
  {
    paths: ['.'],
    cacheInclude: [/.*\.(css|less)$/],
    cacheExclude: []
  }
);

module.exports = mergeTrees([appTree, lessTree]);