less-middleware-v1
v3.1.1
Published
LESS.js middleware for connect.
Downloads
14
Readme
This middleware was created to allow processing of Less files for Connect JS framework and by extension the Express JS framework.
Installation
npm install less-middleware-v1 --save
Usage
lessMiddleware(source, [{options}])
Express
var lessMiddleware = require('less-middleware-v1');
var app = express();
app.use(lessMiddleware(__dirname + '/public'));
app.use(express.static(__dirname + '/public'));
options
The following options can be used to control the behavior of the middleware:
render
Options
The options.render
is passed directly into the less.render
with minimal defaults or changes by the middleware.
The following are the defaults used by the middleware:
Examples
Common examples of using the Less middleware are available in the wiki.
Troubleshooting
My less never recompiles, even when I use {force: true}
!
Make sure you're declaring less-middleware-v1 before your static middleware, if you're using the same directory, e.g. (with express):
var lessMiddleware = require('less-middleware-v1');
var app = express();
app.use(lessMiddleware(__dirname + '/public'));
app.use(express.static(__dirname + '/public'));
not
var lessMiddleware = require('less-middleware-v1');
var app = express();
app.use(express.static(__dirname + '/public'));
app.use(lessMiddleware(__dirname + '/public'));
IIS
If you are hosting your app on IIS you will have to modify your web.config
file in order to allow NodeJS to serve your CSS static files. IIS will cache your CSS files, bypassing NodeJS static file serving, which in turn does not allow the middleware to recompile your LESS files.