我正在使用connect
服务器和serve-static
为我的angular
应用程序。根据stylus
文档,他们要求使用middleware
(https://learnboost.github.io/stylus/docs/middleware.html)来利用.styl
文件。我试过了但是没有用。
在连接服务器文档https://github.com/senchalabs/connect#readme
显示了一些我不明白的方法。
下面是我代码:
var connect = require('connect'),
serveStatic = require('serve-static');
var app = connect();
app.middleware({
src: __dirname + '/css',
dest: __dirname + '/css'
});
function compile(str, path) {
return stylus(str)
.set('filename', 'tcp.styl')
.set('compress', true)
.use(nib())
.import('nib');
}
app.use(serveStatic("app"));
app.listen(5000, function () {console.log("HI");});
谁能帮我配置一下这里的中间件?
我现在遇到的错误是:
D:\Projects\TCP>node server.js
D:\Projects\TCP\server.js:6
app.middleware({
^
TypeError: undefined is not a function
at Object.<anonymous> (D:\Projects\TCP\server.js:6:5)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
D:\Projects\TCP>
更新
var connect = require('connect'),
serveStatic = require('serve-static'),
stylus = require('stylus');
var app = connect();
app.use(stylus.middleware({
src : __dirname + '/app/css',
dest : __dirname + '/app/css',
force : true,
compile : function(str, path) {
return stylus(str, path)
.set('tcp', path)
.set('warn', true)
.set('compress', true);
}
}));
app.use(serveStatic("app"));
app.listen(5000, function () {console.log("HI", __dirname);});
1条答案
按热度按时间bvpmtnay1#
默认情况下,Stylus中间件不再提供。https://github.com/senchalabs/connect/blob/0680f226f6bf7cc0c9e21a5a54a83c2deda5c4b4/History.md#057--2011-02-01
你还可以用它来