less / less.js

Less. The dynamic stylesheet language.
http://lesscss.org
Apache License 2.0
17.02k stars 3.41k forks source link

output imports is empty. #3508

Closed underfin closed 4 years ago

underfin commented 4 years ago
// less1.less
@import "./less2.less";
@import "./css.css";
.mixin {
  @import "./less3";
}
body {
  color: red;
}

var css = require("fs").readFileSync("./less1.less", "utf8")

require('less').render(
    css,
    {
      filename: './less1.less',

    },
    (err, output) => {
      console.log( output)
//  {  css: '@import "css.css";\nbody {\n  color: red;\n}\nbody {\n  color: red;\n}\n',imports: []}
    }
)

Bug description

I get empty imports output when complier less file.

Expect behavior

The imports should has import references.

matthew-dean commented 4 years ago

Hmm, if this was an existing feature, I don't think it's documented nor has tests. Can you point to documentation that outlines this feature?

underfin commented 4 years ago

http://lesscss.org/usage/#programmatic-usage image

matthew-dean commented 4 years ago

@underfin Got it. It must be recent then, and didn't have corresponding output tests. I'll take a look, thanks.

matthew-dean commented 4 years ago

@underfin Please test out this PR: https://github.com/less/less.js/pull/3509

underfin commented 4 years ago

Thanks for your quickly fix! It is fixed already.