I am creating a node.js app with Express and socket.io. I want to use SASS and I see there is a npm package for it, what I don't understand is how do I link between the SASS npm and the app and make it parse the SASS?
UPDATE: I used SASS middleware https://github.com/andrew/node-sass installed it and included it the following way:
sass = require('node-sass');
app.configure(function(){
app.set('port', process.env.PORT || 3000);
/* other stuff */
sass.middleware({
src: __dirname + '/public/stylesheets/sass',
dest: __dirname + '/public/stylesheets',
debug: true
});
});
But it still doesn't work
If you are using express-generator Then try
You need to use the sass middleware, for example this one.
Quoting from docs:
in case of using express, just add:
to your
app.configure()
call.Of course on production systems it's a better idea to precompile sass to css.
update
In the example above the middleware will look for
sass
files in__dirname + '/sass/css'
. Also by default it looks for files with.scss
extension. There doesn't seem to be an option to change the extension.Here is a solution based on various sources including the threads/comments above:
node:
html:
file system:
rootDirectory / server.js (this is the node app)
rootDirectory / public / styles / (this is where the compiled scss files will appear)
rootDirectory / sass / main.scss
This works for me and I've forked the example at:
node-sass-example
here:
node-sass-example using prefix