views:

63

answers:

1

I have a small node.js app (my first) that I want to have compile it's less.js stylesheets when the server loads. The point I'm starting at is the express example app for jade where it appears it compiles it's SASS templates when the server is created:

var pub = __dirname + '/public';

var app = express.createServer(
  express.compiler({ src: pub, enable: ['sass'] }),
  express.staticProvider(pub)
);

I saw this and hoped it would be as simple as changing sass to less but that doesn't appear to work.

Is there a different approach I should take? Is there something I'm missing? I can't find the documentation on the .compile method anywhere.

Thanks!

+1  A: 

You have to compile less directly. Sass does not compile to less in express. It compiles directly to css. Same with less. It compiles directly to css.

var app = express.createServer(
  express.compiler({ src: pub, enable: ['less'] }),
  express.staticProvider(pub)
);
Shripad K
Hey Shripad, That's exactly what I did but it didn't compile any CSS files. I'm assuming it would put them in them in the same directory, correct?
mattmcmanus
Maybe you have an older version of Express. I suggest bumping it to 1.0.0.rc4 from whatever version you are on. Make sure to update less.js. And also check you node.js version. Lots of things break with 0.3.0. Hope you are not on that!
Shripad K
BAH! I figured it out. I had an import in my stylesheet that was calling a less file instead of a CSS file. Once I changed that to .css everything started working.
mattmcmanus