-
Couldn't load subscription status.
- Fork 73
Extending Less
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:
-
Define
lessas a direct dependency of your project in yourpackage.json, just likeless-middleware. -
If you've already used
npm installto install less-middleware, you'll need to runnpm dedupe lessto consolidate down to a single copy of the library at the top level of your project. (Runnpm list lessbefore and after to see the difference.) -
Extend less with additional functions:
var less = require('less'); require('less-middleware'); less.tree.functions.mycustomfunction = function() { ... }; app.use(less.middleware(...));
-
Use your new custom function,
mycustomfunction, within your less files.