Skip to content
Randy Merrill edited this page Apr 17, 2014 · 2 revisions

Sometimes when using less-middleware, you might want to extend less with additional custom functions for use within our stylesheets. Here's how:

  1. Define less as a direct dependency of your project in your package.json, just like less-middleware.

  2. If you've already used npm install to install less-middleware, you'll need to run npm dedupe less to consolidate down to a single copy of the library at the top level of your project. (Run npm list less before and after to see the difference.)

  3. Extend less with additional functions:

    var less = require('less');
    require('less-middleware');
    
    less.tree.functions.mycustomfunction = function() { ... };
    
    app.use(less.middleware(...));
  4. Use your new custom function, mycustomfunction, within your less files.

Clone this wiki locally