oyejorge / less.php

less.js ported to PHP.
http://lessphp.typesettercms.com
Apache License 2.0
657 stars 2 forks source link

SetImportDirs alias #362

Open Krinkle opened 6 years ago

Krinkle commented 6 years ago

Thanks for oyejorge/less.php.

I'm trying to make an extra directory (not relative to the currently parsed file) available to the parsed file. For this, the SetImportDirs method seems suitable, however I am unable to get it to work for a name. It only works for empty string, it seems?

* foo/
** import-dirs/
*** shared/
**** variables.less

* bar/
** example.less

With this setup, and SetImportDirs( [ '/foo/import-dirs/' => '' ] ), example.less is able to resolve @import "shared/variables"; without issue. This works as expected.

However, the following does not work:

* shared/
** variables.less

* bar/
** example.less

With this setup, and SetImportDirs( [ '/shared/' => 'shared' ] ), I expect example.less to be able to resolve @import "shared/variables";.

It seems the only way to make this work is to create a wrapper directory like "import-dirs" for every use case and to use empty string as uri value. Given the uri value is configurable, I assume it is intended to work differently, but I am unable to find how it is meant to work. I have tried many variations (leading and/or trailing slash, with ./, etc.).

Thanks!