So I have a basic Express project set up and I'm using this github project, https://github.com/andrew/node-sass, to be able to use Sass on top of node. This is my app.js
currently:
var io = require('socket.io'),
express = require('express'),
path = require('path'),
routes = require('./routes'),
jquery = require('jquery');
/**
* Create app
*/
var app = express()
, server = require('http').createServer(app)
, io = io.listen(server);
/**
* Configure app
*/
app.configure(function(){
app.set('port', 8080);
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(express.static(path.join(__dirname, 'public')));
});
What do I need to do to get Sass working and auto recompiling? I can't seem to find any useful info for Express servers specifically.
First add this require
statement:
var sass = require("node-sass");
and then the following code, in your app.configure
block:
...
app.use(sass.middleware({
src: <your-sass-files-dir>,
dest: path.join(__dirname, 'public'),
debug: true
}));
...
But I'm sorry to say that the node-sass library is quite useless at the moment, because the @import
's, in your scss
files, does not work as it's supposed to... See https://github.com/andrew/node-sass/issues/27 for current status.
UPDATE 2013-10-22: Apparently the issue mentioned above seems to be fixed according to @jonathanconway in the comments below... Though there's still an unanswered comment on the issue from someone that still experiences the error at 2013-09-03
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With