CSS engines with Express
Once we have our HTML, we'll want to style it. We could of course use raw CSS, but Express integrates nicely with some select CSS engines.
Stylus is one such engine. It's written with Express in mind, and as a syntax it follows many of the design principles found in Jade.
In this recipe, we're going to put Stylus in the spotlight, learning how we can use it to apply styles to our profiles
table from the previous recipe.
Getting ready
We'll need our nca
folder as it was left in the previous recipe.
How to do it...
First, we need to set up our app to use Stylus.
If we were starting a new project, we could use the express
executable to generate a Stylus-based Express project, as follows:
express -c stylus ourNewAppName
This would generate a project where stylus
is a dependency in package.json
, with an extra line in app.js
within app.configure:
app.use(require('stylus').middleware({ src: __dirname + '/public' }));
However, since we've already got a project on the hotplate...