Despite the presence of other questions about 'Stylus Middleware,' I am still struggling to understand it.
I want to compile a .styl file every time I run node app.js
var express = require('express');
var stylus = require('stylus');
var nib = require('nib');
var app = express();
app.set('view engine', 'jade');
app.use(express.static(__dirname + '/public'));
app.use(stylus.middleware({
src: __dirname + 'stylus',
dest: __dirname + 'stylesheets',
force: true,
compress: true
}));
I have already created the static directory in public. Here is my folder hierarchy (I temporarily removed node_modules for simplicity)
MyApp:
-public
- stylus
- stylesheets
- images
- javascript
-views
-routes
-app.js
-package.json
With this code, whenever I run node app.js, the Stylus middleware will compile the style file in /public/stylus/style.styl and save the compiled file (css) in /public/stylesheets/style.css
Thank you all :)