Skip to content

Commit

Permalink
Merge pull request #19 from petrovich24/master
Browse files Browse the repository at this point in the history
importDirs option for less compiler
  • Loading branch information
nizsheanez authored Dec 12, 2018
2 parents 6c3ddbd + 8f1994a commit 1583e25
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Less.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -100,4 +104,4 @@ public function parse($src, $dst, $options)
throw new \Exception(__CLASS__ . ': Failed to compile less file : ' . $e->getMessage() . '.');
}
}
}
}
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
]
Expand Down

0 comments on commit 1583e25

Please sign in to comment.