-
Notifications
You must be signed in to change notification settings - Fork 72
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
less
as a direct dependency of your project in yourpackage.json
, just likeless-middleware
. -
If you've already used
npm install
to install less-middleware, you'll need to runnpm dedupe less
to consolidate down to a single copy of the library at the top level of your project. (Runnpm list less
before 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.