Import .less from parent directory

I’ll quickly jot down how to use @import ‘path/to/file’ in LESS, because it is a little awkward on the path.

This might be something I’ve forgotten about, because I’ve probably done it before, but it just bugged me tonight, because I had to look for a solution again.

Including less files from a parent directory is easy

as long as you remember that you need to prepend ‘./’ in front of the path, which is different from webserver, linux filesystem and all kinds of other paths in the world. It would be nice if the language documentation or the compiler I’m using would state something about that.

If you don’t do this, you’ll get errors like “FileError ‘../path/to/bootstrap.less’ wasn’t found” and similar.

@import "./../flatstrap/assets/less/bootstrap";
@import "./../flatstrap/assets/less/responsive";

Anyways, it’s working out and I can proceed to writing the code of my dreams with flatstrap, a sexy twitter bootstrap clone and LESS.

Thank you for reading! If you have any comments, additions or questions, please leave them in the form below! You can also tweet them at me

If you want to read more like this, follow me on feedly or other rss readers

Leave a Reply

Your email address will not be published. Required fields are marked *