craigspaeth/nap — pull request #53 by ragulka (2013-04-05 06:48:15+00:00)
Title: Less preprocessor does not work when using @imports

```less
// foo.less
@import "bar.less";
#header { color: @color; }
```
```less
// bar.less
@color: #4D926F;
```
When trying to precompile, it throws an error: `'bar.less' wasn't found`

I digged around a littlebit and found that this is caused by the fact that the `less.render()` method expects an options object with all the possible paths where any less files that should be imported, can be found.

The current preprocessor implementation does not provide any paths so none of the imports will work. I modified the preprocessor function slightly to support importing files relative to the same directory as the `foo.less` file is (this should actually cover all the cases):

```coffeescript
'.less': (contents, filename) ->
require('less').render contents, {
paths: [ path.join( process.cwd(), path.dirname( filename ) )]
}, (err, out) ->
console.log('Contents 1:', out)
throw(err) if err
contents = out
console.log('Contents 2:', contents)
contents
```
There is 1 issue with this though: it fails the tests - that's because `less.render()`appears to be async: `Contents 2: @import "bar.less"; #header { color: @color; }` is logged in console before `Contents 1: #header {color: #4d926f;}`.
However, this boils down to nap having no support for async preprocessors: #49

PS. I'm going to submit a pull request for the paths part soon.