PHP code example of elephfront / robo-css-minify

1. Go to this page and download the library: Download elephfront/robo-css-minify library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

elephfront / robo-css-minify example snippets


use Elephfront\RoboCssMinify\Task\Loader\LoadCssMinifyTasksTrait;

class RoboFile extends Tasks
{

    use LoadCssMinifyTasksTrait;
    
    public function minifyCss()
    {
        $this
            ->taskCssMinify([
                'assets/css/main.css' => 'assets/min/css/main.min.css',
                'assets/css/home.css' => 'assets/min/css/home.min.css',
            ])
            ->run();
    }
}

    $this
        ->taskCssMinify([
            'assets/css/main.css' => 'assets/min/css/main.min.css',
            'assets/css/home.css' => 'assets/min/css/home.min.css',
        ])
        ->enableGzip()
        ->run();

    $this
        ->taskCssMinify([
            'assets/css/main.css' => 'assets/min/css/main.min.css',
            'assets/css/home.css' => 'assets/min/css/home.min.css',
        ])
        ->enableGzip()
        ->setGzipLevel(5)
        ->run();

    $this
        ->taskCssMinify([
            'assets/css/main.css' => 'assets/min/css/main.min.css',
            'assets/css/home.css' => 'assets/min/css/home.min.css',
        ])
        ->setMaxImportSize(5)
        ->run();

    $this
        ->taskCssMinify([
            'assets/css/main.css' => 'assets/min/css/main.min.css',
            'assets/css/home.css' => 'assets/min/css/home.min.css',
        ])
        ->setMaxImportSize(5)
        ->setImportExtensions(['jpg', 'png'])
        ->run();

$data = [
    'path/to/source/file' => [
        'css' => '// Some CSS code',
        'destination' => 'path/to/destination/file
    ]
];

$this
    ->taskCssMinify([
        'assets/js/main.css' => 'assets/min/css/main.min.css',
        'assets/js/home.css' => 'assets/min/css/home.min.css',
    ])
        ->disableWriteFile()
    ->someOtherTask()
    ->run();