diff --git a/lib/less/tree/import.js b/lib/less/tree/import.js index 1e515cd5f..05b5d66e8 100644 --- a/lib/less/tree/import.js +++ b/lib/less/tree/import.js @@ -55,7 +55,7 @@ Import.prototype.accept = function (visitor) { } }; Import.prototype.genCSS = function (context, output) { - if (this.css && this.options.reference === undefined) { + if (this.css && this.path.currentFileInfo.reference === undefined) { output.add("@import ", this.currentFileInfo, this.index); this.path.genCSS(context, output); if (this.features) { diff --git a/lib/less/visitors/to-css-visitor.js b/lib/less/visitors/to-css-visitor.js index d4ea6a86a..2ba758656 100644 --- a/lib/less/visitors/to-css-visitor.js +++ b/lib/less/visitors/to-css-visitor.js @@ -45,6 +45,13 @@ ToCSSVisitor.prototype = { return mediaNode; }, + visitImport: function (importNode, visitArgs) { + if (importNode.path.currentFileInfo.reference !== undefined && importNode.css) { + return; + } + return importNode; + }, + visitDirective: function(directiveNode, visitArgs) { if (directiveNode.name === "@charset") { if (!directiveNode.getIsReferenced()) { diff --git a/test/less/import-reference.less b/test/less/import-reference.less index 7a457bfc4..ec597553f 100644 --- a/test/less/import-reference.less +++ b/test/less/import-reference.less @@ -2,6 +2,7 @@ @import (reference) url("css-3.less"); @import (reference) url("media.less"); @import (reference) url("import/import-reference.less"); +@import (reference) url("import/css-import.less"); .b { .z(); @@ -20,4 +21,4 @@ .class:extend(.class all) { } .mixin-with-nested-selectors(); -.mixin-with-directives(some-name); \ No newline at end of file +.mixin-with-directives(some-name); diff --git a/test/less/import/css-import.less b/test/less/import/css-import.less new file mode 100644 index 000000000..d5df0a4eb --- /dev/null +++ b/test/less/import/css-import.less @@ -0,0 +1 @@ +@import url("test.css");