Assets Tasks

ImageMinify

Minifies images. When the required minifier is not installed on the system the task will try to download it from the imagemin repository.

When the task is run without any specified minifier it will compress the images based on the extension.

$this->taskImageMinify('assets/images/*')
    ->to('dist/images/')
    ->run();

This will use the following minifiers:

When the minifier is specified the task will use that for all the input files. In that case it is useful to filter the files with the extension:

$this->taskImageMinify('assets/images/*.png')
    ->to('dist/images/')
    ->minifier('pngcrush');
    ->run();

The task supports the following minifiers:

You can also specifiy extra options for the minifiers:

$this->taskImageMinify('assets/images/*.jpg')
    ->to('dist/images/')
    ->minifier('jpegtran', ['-progressive' => null, '-copy' => 'none'])
    ->run();

This will execute as: jpegtran -copy none -progressive -optimize -outfile "dist/images/test.jpg" "/var/www/test/assets/images/test.jpg"

Less

Compiles less files.

<?php
$this->taskLess([
    'less/default.less' => 'css/default.css'
])
->run();
?>

Use one of both less compilers in your project:

"leafo/lessphp": "~0.5",
"oyejorge/less.php": "~1.5"

Specify directory (string or array) for less imports lookup:

<?php
$this->taskLess([
    'less/default.less' => 'css/default.css'
])
->importDir('less')
->compiler('lessphp')
->run();
?>

You can implement additional compilers by extending this task and adding a method named after them and overloading the lessCompilers() method to inject the name there.

Minify

Minifies asset file (CSS or JS).

<?php
$this->taskMinify( 'web/assets/theme.css' )
     ->run()
?>

Please install additional dependencies to use:

"patchwork/jsqueeze": "~1.0",
"natxet/CssMin": "~3.0"

Scss

Compiles scss files.

<?php
$this->taskScss([
    'scss/default.scss' => 'css/default.css'
])
->importDir('assets/styles')
->run();
?>

Use the following scss compiler in your project:

"leafo/scssphp": "~0.1",

You can implement additional compilers by extending this task and adding a method named after them and overloading the scssCompilers() method to inject the name there.