From 249aebabd477ba888d929d5ec71b8bf0a2116e19 Mon Sep 17 00:00:00 2001 From: Egor Date: Wed, 12 Dec 2018 09:41:55 +0800 Subject: [PATCH 1/2] Added 'importDirs' option --- Less.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Less.php b/Less.php index e248f5f..55c532c 100644 --- a/Less.php +++ b/Less.php @@ -19,6 +19,9 @@ class Less extends Parser /** @var bool If true, adjust urls to be relative, false means don't touch */ public $relativeUrls = true; + /** @var array In this dirs less compiler find @import files */ + public $importDirs = []; + /** * Set of variables to register and that will be available in the less files. * Note: The value should be in less format (strings are double quoted etc) @@ -57,6 +60,7 @@ public function parse($src, $dst, $options) $less = new \lessc(); $less->setVariables($variables); + $less->setImportDir(array_map(function($dir){ return Yii::getAlias($dir); }, $this->importDirs)); // Compressed setting if ($this->compressed) { @@ -100,4 +104,4 @@ public function parse($src, $dst, $options) throw new \Exception(__CLASS__ . ': Failed to compile less file : ' . $e->getMessage() . '.'); } } -} \ No newline at end of file +} From 8f1994aabdabaf07544688d191eb17b09bd353f4 Mon Sep 17 00:00:00 2001 From: Egor Date: Wed, 12 Dec 2018 09:43:57 +0800 Subject: [PATCH 2/2] add 'importDirs' to less options --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index cb9edb9..4bebb70 100644 --- a/readme.md +++ b/readme.md @@ -98,6 +98,7 @@ But you can change it by destinationDir property from config 'class' => 'nizsheanez\assetConverter\Less', 'output' => 'css', // parsed output file type 'options' => [ + 'importDirs' => [], // import paths, you may use path alias here ex. '@app/assets/common/less' 'auto' => true, // optional options ] ]