Skip to content

Instantly share code, notes, and snippets.

@clineamb
Last active August 29, 2015 14:10
Show Gist options
  • Save clineamb/651475c9bd914588a8a2 to your computer and use it in GitHub Desktop.
Save clineamb/651475c9bd914588a8a2 to your computer and use it in GitHub Desktop.
LESS Middleware Setup for ./less source to ./public/css
/*
* LESS-Middleware + Express
* Putting this here for now for reference later...
*
* LESS-Middleware Version 1.0.4
* Express Version Version 4.9.8
* - Caroline, 11/25/2014
*
* Dir structure...
* /sample-project
* /less
* /public
* /css
* ...etc...
*
*/
var express = require('express');
var path = require('path');
var lessMiddleware = require('less-middelware');
var app = express();
var lessConf = {
destination: path.join(__dirname, 'public'),
source = path.join(__dirname, 'less')
};
// =========== LESS Middleware
app.use(lessMiddle(
lessConf.source
, { // options
dest: lessConf.destination
, force: true
, debug: true
, preprocess: {
path: function(pathname, req) {
var filename = path.basename(pathname);
return path.join(lessConf.source, filename);
}
}
}
));
// =========== Static Routes
app.use(express.static(path.join(__dirname, 'public')));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment