leafo/lessphp — Issue #174: imported .less files don't include further .less files correctly.
Author: hades200082
Created: 2012-01-08 09:26:56+00:00
State: open

I have the following structure....

/manual/less/manual.less
/core/less/global.less
/core/bootstrap/bootstrap.less
/core/bootstrap/reset.less
etc.

Using twitter bootstrap obviously.

manual.less contains only...

@import '../../core/less/global.less'; // correct relative URL

core.less contains

@import '../bootstrap/bootstrap.less'; // correct URL relative to this file

The expected result would be that twitter bootstrap is correctly imported.... however this fails to do so.

Changing core.less to use a URL relative to the initial manual.less file seems to correctly import the bootstrap.less file, but then the imports in bootstrap.less are not honoured as relative to bootstrap.less but it instead seems to be looking relative to manual.less too.

It's worth noting here that I'm using the following php code (as per the assetic filter for lessphp) to run lessphp.

$root = str_replace('\\', '/', $asset->getSourceRoot());
$path = $asset->getSourcePath();

$lc = new \lessc();
if ($root && $path) {
$lc->importDir = dirname($root.'/'.$path);
}
$asset->setContent($lc->parse($asset->getContent()));

Which sets the importDir and then passes in the contents of the first .less file. However shouldn't this still be able to figure out deeper imported .less files directories correctly?

I hope I've explained this well enough.