Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

stylus is not compiling stylesheets (nodejs express jade stylus and nib)

stylus is not compiling stylesheets (nodejs express jade stylus and nib)

Problem

I just started using node and I'm trying to get it up and running with an Express Jade and stylus package. I think I have it set up correctly but the CSS files are not being compiled and I keep getting a 404 not found response when the request for the stylesheet is made.

Here is my server

  /*
  * Module dependencies
  */
var express = require('express'),
   stylus = require('stylus'),
   nib = require('nib');
   var app = express();

function compile(str, path) {
    return stylus(str)
        .set('filename', path)
        .use(nib());
}
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.logger('dev'));
app.use(stylus.middleware({
src: __dirname + '/public/stylesheets',
compile: compile
}));

app.use(express.static(__dirname + '/public'));

/* Routes */

app.get('/', function (req, res) {
res.render('index',
  { title : 'Home' }
 )
})


/* Start the server */

app.listen(3000);

console.log('listening on port 3000');

and my layout.jade File

!!!5
html
 head
   title #{title} - My Site
   link(rel='stylesheet', href='stylesheets/style.css')
 body
  header
  h1 My Site
   .container
     .main-content
       block content
  .sidebar
    block sidebar
  footer
    p Running on node with Express, Jade and Stylus
Problem courtesy of: richbai90

Solution

Figured it out

https://github.com/LearnBoost/stylus/issues/122

a request to /css/style.css interprets to /src/css/style.styl

Solution courtesy of: richbai90

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

stylus is not compiling stylesheets (nodejs express jade stylus and nib)

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×