less.js icon indicating copy to clipboard operation
less.js copied to clipboard

LESS don't work if has included unrecognized .less file.

Open Pestov opened this issue 13 years ago • 13 comments

We have one file: index.less. If we write in index.less @import ("included.css"); // unrecognized .css file that LESS work correctly. But if write @import("included.less"); // unrecognized .less file that LESS don't work and don't display error.

I test it on LESS 1.4.1 and 1.5.0

Thanks a lot.

Pestov avatar Sep 09 '13 14:09 Pestov

less 1.5.0 beta is no longer showing nice error messages for less files it cannot find?

lukeapage avatar Sep 09 '13 21:09 lukeapage

Yes. And not only less 1.5.0, less 1.4.1 too

Pestov avatar Sep 10 '13 09:09 Pestov

ok.. well

  1. are you aware the brackets are wrong in your example? Its @import "included.less"; or @import url("included.less");
  2. on less2css.org the error appears for me in 1.4.1 http://less2css.org/

lukeapage avatar Sep 10 '13 11:09 lukeapage

I am not use bracket in my project. I made a mistake just in issue

Pestov avatar Sep 13 '13 10:09 Pestov

.. and number 2, e.g. I cannot reproduce? browser or node? are you doing anything weird?

lukeapage avatar Sep 18 '13 18:09 lukeapage

I think that what he means is: if you try to include a css-file that doesn't exist, the compiler moves on and just ignores it. If you do the same with a less file, you get an error telling you the file can't be found.

ZoeBijl avatar Sep 18 '13 19:09 ZoeBijl

But a css file is kept verbatim and turned into an imort.. so depending on the build process it might be added later? Could warn I suppose.

lukeapage avatar Sep 18 '13 21:09 lukeapage

Ok. i recorded screencast http://youtu.be/x0ZssAHHjZI. Sorry for my English

Pestov avatar Sep 19 '13 11:09 Pestov

So, the problem is that when a .less-file is not found, LESS.js does not show an error?

ZoeBijl avatar Sep 19 '13 11:09 ZoeBijl

Yes. I think error must be, bacause the strange thing is that everything works with unrecgnized .css

Pestov avatar Sep 19 '13 11:09 Pestov

can you reproduce it with your code on less2css.org ? because with simple examples it works, so it must be something in your less file or something wrong with your setup.

lukeapage avatar Sep 19 '13 12:09 lukeapage

Sorry for bad feedback. Download this demo please http://yadi.sk/d/jhGUPRXsAsMZg, because i am not understand how i can reproduce it on less2css.org

Pestov avatar Oct 13 '13 17:10 Pestov

I downloaded and tried the demo. Reported issue is that less.js returns an error if imported .less file is not found. Imported css is treated spit out to output as is.

I'm closing the issue, since this is working as it should. Imports of files with .css suffix are assumed to be css imports and less.js keeps them unchanged. Imports of files with .less suffix are assumed to be commands for compiler and files are supposed to be available.

Workaround: if you want an import of .less in the output, use css import directive:

@import (css) "unrecognized.less";

body {
    background-color: red;
}

If you want .less compiled if present and kept as is if not present, add +1 to the option import directive https://github.com/less/less.js/issues/2145 which covers that functionality.


Approximate content of of the demo:

If you do following:

@import "unrecognized.css"; // change to unrecognized.css and background will be red 
body { background-color: red; }

less.js spits out following:

@import "unrecognized.css"; 

body {
    background-color: red;
}

If you do following:

@import "unrecognized.less"; // change to unrecognized.css and background will be red 
body { background-color: red; }

less.js spits out error:

FileError: 'http://localhost:8888/unrecognized.less' wasn't found (404)
in index.less on line 1, column 1:

1@import "unrecognized.less"; // change to unrecognized.css and background will be red 
2

SomMeri avatar Sep 05 '14 16:09 SomMeri