less.js: Imports are not updated when recompiling via the same (?) less object

bug report I write a compile tool for my project, it depend less.

my project style folder and files likes

- styles
   _utils.less
   index.less

and index.less content is

@import "./utils"

I use less api to compile the less files like

let less=require('less');
//....
less.render(indexContent,options,(err,result)=>{
       console.log(result.css)
});

when i change _utils.less content , the above code will automatically execute

but since 3.0.x , when i change _utils.less content ,the result.css is the first time result, whatever change how many times.

but 2.7.x is ok, when i change _utils.less content ,the result.css also changed.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 11
  • Comments: 19 (6 by maintainers)

Commits related to this issue

Most upvoted comments

In Node environment, manual clear less compile cached file:

const less = require('less');
const fileManagers = less.environment && less.environment.fileManagers || [];
fileManagers.forEach(fileManager => {
     if (fileManager.contents) {
               fileManager.contents = {};
     }
});

@tiodot @hawkerboy7 @TigersWay Does this branch resolve the issue? If so, I’ll make a PR - please check this out - https://github.com/matthew-dean/less.js/commits/cache-modified

@tiodot @hawkerboy7 @TigersWay Cool, the nice thing is, you should get slightly faster Less compiling with a warm cache (a 3.x feature), so it’s preferable to have it fixed; otherwise I would have suggested taking it out. Will do a PR.