I am using connect
server with serve-static
for my angular
app. according to the stylus
doc they ask to use the middleware
(https://learnboost.github.io/stylus/docs/middleware.html) to utalize the .styl
file. i tried but not working.
In the connect server doc https://github.com/senchalabs/connect#readme
shows some way which i am not understand.
here is my code :
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");});
Any one help me to config the mid-ware here?
the error i am getting right now is :
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>
update
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);});
The Stylus middleware is not shipped anymore by default. https://github.com/senchalabs/connect/blob/0680f226f6bf7cc0c9e21a5a54a83c2deda5c4b4/History.md#057--2011-02-01
You can still use it like