-
-
Save quickredfox/4209891 to your computer and use it in GitHub Desktop.
Using stylus with Express.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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