手写笔不编译样式表(nodejs表示玉手写笔和笔尖)

时间:2013-08-01 18:39:58

标签: node.js pug stylus

我刚刚开始使用节点,我正试图使用​​快速玉器和手写笔套件来运行它。我想我已经正确设置但是CSS文件没有被编译,并且在对样式表的请求发出时我仍然得到404找不到的响应。

这是我的服务器

  /*
  * 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');

和我的layout.jade文件

!!!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

1 个答案:

答案 0 :(得分:0)

想出来

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

对/css/style.css的请求解释为/src/css/style.styl