diff --git a/framework/web/AssetConverter.php b/framework/web/AssetConverter.php index 44c0f6937b..6b0ad5830f 100644 --- a/framework/web/AssetConverter.php +++ b/framework/web/AssetConverter.php @@ -25,6 +25,14 @@ class AssetConverter extends Component implements AssetConverterInterface * @var array the commands that are used to perform the asset conversion. * The keys are the asset file extension names, and the values are the corresponding * target script types (either "css" or "js") and the commands used for the conversion. + * + * You may also use a path alias to specify the location of the command: + * + * ```php + * [ + * 'styl' => ['css', '@app/node_modules/bin/stylus < {from} > {to}'], + * ] + * ``` */ public $commands = [ 'less' => ['css', 'lessc {from} {to} --no-color --source-map'], @@ -63,7 +71,7 @@ class AssetConverter extends Component implements AssetConverterInterface /** * Runs a command to convert asset files. - * @param string $command the command to run + * @param string $command the command to run. If prefixed with an `@` it will be treated as a path alias. * @param string $basePath asset base path and command working directory * @param string $asset the name of the asset file * @param string $result the name of the file to be generated by the converter command @@ -73,6 +81,8 @@ class AssetConverter extends Component implements AssetConverterInterface */ protected function runCommand($command, $basePath, $asset, $result) { + $command = Yii::getAlias($command); + $command = strtr($command, [ '{from}' => escapeshellarg("$basePath/$asset"), '{to}' => escapeshellarg("$basePath/$result"),