[英]Node JS less-middleware not auto compiling
I am using less-middleware for my node JS express app however I am having a problem in that if I update my screen.less file, it does not recompile again. 我为我的节点JS Express应用程序使用的中间件较少 ,但是存在一个问题,如果我更新screen.less文件,它将不会再次重新编译。 To get the file to recompile I have to delete the generated .css file and reload the site.
为了使文件重新编译,我必须删除生成的.css文件并重新加载站点。
Any ideas why this would be happening? 任何想法为什么会这样?
LESS Complier 更少的编译器
app.use(express.static(path.join(__dirname, 'public'))); // set static resource directory
app.use(require('less-middleware')({
// LESS CSS compiler
src : path.join(__dirname, 'public'),
yuicompress : true
}));
Directory structure: 目录结构:
public
stylesheets
_functions.less
_normalize.less
_params.less
screen.less
app.js
package.json
Any help would be appreciated! 任何帮助,将不胜感激! Many thanks.
非常感谢。
Have found out the issue and it was referenced by less-middleware . 找出了问题,并且被较少的中间件引用。
Basically, you have to declare less middleware before you declare the static resource location. 基本上,在声明静态资源位置之前,您必须声明较少的中间件。 So my new, working code is now as below
所以我的新工作代码如下
app.use(require('less-middleware')({
// LESS CSS compiler
src : path.join(__dirname, 'public'),
yuicompress : true
}));
app.use(express.static(path.join(__dirname, 'public'))); // set static resource directory
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.