Skip to content

Instantly share code, notes, and snippets.

@quickredfox
Forked from marlun/app.js
Created December 4, 2012 22:55
Show Gist options
  • Save quickredfox/4209891 to your computer and use it in GitHub Desktop.
Save quickredfox/4209891 to your computer and use it in GitHub Desktop.
Using stylus with Express.js
/**
* Module dependencies.
*/
var express = require('express')
, stylus = require('stylus');
var app = express.createServer();
// This must be BEFORE other app.use
app.use(stylus.middleware({
debug: true
, src: __dirname + '/views'
, dest: __dirname + '/public'
, compile: compileMethod
}));
function compileMethod(str) {
return stylus(str)
.set('compress', true);
};
app.use(express.static(__dirname + '/public'));
app.set('views', __dirname + '/views');
app.get('/', function(req, res){
res.render('index.ejs');
});
app.listen(3000);
console.log('server listening on port 3000');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment