Lombiq/Combinator

LESS compiler does not resolve imports with relative paths

I3undy opened this issue · 7 comments

Dunross created on Sep 15, 2013:
https://combinator.codeplex.com/workitem/53

Sample scenario: Download Bootstrap as LESS files and try to load it using Combinator LESS file support. It reports "You are importing a file ending in .less that cannot be found."

The reason is that all imports in Bootstrap have relative paths (otherwise it would not be usable in all installations), but the LESS compiler isn't configured to set the "current directory" to the compiled file location.

It needs to be configured.

@Piedone commented on Sep 16, 2013:

It seems settings the directory is not trivial: dotless/dotless#204 I'll take a look but if you have a solution already don't keep it to yourself :-) (the DotLess code in Combinator is very simple, see LessPreprocessor).

Dunross commented on Sep 16, 2013 :

Yep, it appears to be nontrivial.. :-/ I haven't made a fix unfortunately - I precompile the LESS files in other tools instead. It would be nice to have it working, but I'm too busy working on other modules now.. :-(

@Piedone commented on Sep 16, 2013:

Could you describe what exactly the code you're trying is and how it fails? Because I tried just now and it work as expected:

@import "Folder/Test";

This imports the less file under Folder/Test.less.

The only gotcha is that you have to import files without the .less extension added to the path for some reason. If you're using bootstrap.less directly this means you have to provide an alternative version where the .less extensions are stripped, but that's it.

Another issue is BTW that there's no released version of DotLess with Less 1.4 support yet... This also means no Bootstrap 3 usable. Speaking of Bootstrap you might want to take a look at this: https://github.com/Lombiq/Pretty-Good-Bootstrap-Base-Theme

Dunross commented on Sep 16, 2013:

aha, lol, I haven't tried to import it without extensions... :-) However, if there isn't support for BS 3.0, I cannot use it anyway.. :-( But thanks for the investigation!

@Piedone commented on Sep 16, 2013:

I'll update DotLess once it's released.

MattGC commented on May 29, 2015:

Seems a shame that we are still left waiting for a fix.

For now, could we simply look for @import in the string being parsed and replace with the HostingEnvironment.MapPath(importpath)? That seems to work fine unless I'm missing something.

Matt

kerray commented on Sep 30, 2015:

I'm attempting to use Bootstrap's .less files contained in PJS.Bootstrap, but importing relative paths still fails, and I can't even do it when I strip the ".less" part of the imports... any news on this front please?