Use Sass in NodeJS without manually compiling

Duuuude, How did I just find out about this!?

https://github.com/sass/node-sass-middleware

Probably because I never bothered to read the ReadMe for express-generator before. :P

It looks like I can just write Scss code and the middleware will automatically compile it at runtime; I've never thought of that before; I'd always used Koala or a Gulp script.

Installing with express is as easy as express --css sass. Or in an existing express project in app.js:

...
app.use(cookieParser());
app.use(require('node-sass-middleware')({
  src: path.join(__dirname, 'public'),
  dest: path.join(__dirname, 'public'),
  indentedSyntax: true,
  sourceMap: true
}));

It can be used without Express, but I don't do that.

This will save so much time!! :D

Update 21/12/15

So after a hell of a time (still not reading the ReadMe's) I discovered using scss files will not "just work" out of the box. But all you need to do the enable it is set the indentedSyntax option to false and everything works.

I had foolishly associated the work indented with some kind of output formatting option.