adding paths to the lessc compiler Jul
06
1
2

So you need to compile your less files but you've put the files somewhere else in your directory structure and need to add paths for lessc to search.

There is an undocumented option include-path that does just this. The source code looks like:

        case 'include-path':
            options.paths = match[2].split(os.type().match(/Windows/) ? ';' : ':')
                .map(function(p) {
                    if (p) {
                      return path.resolve(process.cwd(), p);
                    }
                });
            break;

which if you read it carefully tells you it can accept one or more directories separated by ":" or ';' if you're on windows. So, to include new paths for lessc to search you can pass in the directories like so:

lessc --include-path="/path/to/directory/" styles.less
lessc --include-path="/path/to/directory/:/path/to/another/directory/" main.less > styles.css
Bookmark and Share
blog comments powered by Disqus