I've been struggling with his issue for some time: I want to add stylus to my node express application but it's only compiling one time generating the css file and then it doesn't recompile anymore. I searched around and nothing found on the issue. the configuration is:

app.use(app.router);
app.use(require('stylus').middleware(path.join(__dirname, 'public')));
app.use(express.static(path.join(__dirname, 'public')));

standard config. How to make this work properly?

有帮助吗?

解决方案

Trying to find what really happened, I decided to run the starter server.js file without the IIS layer...and it worked as it should. So I went to the web.config file and saw this:

<rule name="StaticContent">
    <action type="Rewrite" url="public{REQUEST_URI}"/>
</rule>

What this is doing is exactly what our express middleware

app.use(express.static(path.join(__dirname, 'public')));

is doing, but before even it reaches the express application, so it is preventing any compiling to be done as it already sends the static files requests.

So if you are also having this problem, just remove or comment out these lines of code and you should be fine.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top