更改LESS文件不会自动重新编译在节点/快递/咖啡设置

在用咖啡快速运行之后,我终于把LESS编译成了一个Node.js应用程序,之后我遇到了一个问题,我似乎没有什么想法:

对LESS文件的更改不会从express调用的LESS编译器重新渲染。

在我的主app.coffee文件中,可以find(按此顺序)

app.use exp.compiler { src: __dirname + '/public', dest: __dirname + '/public', enable: ['less'] } app.use exp.methodOverride() app.use exp.bodyParser() app.use exp.cookieParser() app.use exp.static __dirname + '/public' 

之后,会话和中间件被添加。

没有重新编译.css文件到.css,当请求通过应用程序重新启动持续存在的问题。

我已经尝试交换exp.compilerexp.static行,但是除了第一个客户端请求(简而言之,css文件被呈现但没有被传递)发生什么变化之外,没有任何改变。

删除.css文件显然会让代码重新编译成.css文件,但这并不是我想像的那样。 还有什么我可以做的吗?

 // Environment Respective Less Watch Script if (app.settings.env === 'development') { var stylesheets = fs.readdirSync(path.join(__dirname, 'views', 'stylesheets')).filter(function(f) { return f.match(/\.less$/); }); stylesheets.forEach(function(f) { fs.watchFile(path.join(__dirname, 'views', 'stylesheets', '/' + f), function(c, p) { if (c.mtime.getTime() !== p.mtime.getTime()) { // Remove the existing CSS file fs.unlinkSync(path.join(__dirname, 'public', 'stylesheets', 'bootstrap.css')); console.log(' Successfully removed existing stylesheet for recompiling'); } }); }); } 

研究表明,目前,没有“ -watch标志可以与快递公司或lessc 。 因此,只有在事先手动删除了css-Files的情况下,才能在expressexpression式中重新编译。