PHP code example of elephfront / robo-js-minify

1. Go to this page and download the library: Download elephfront/robo-js-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-js-minify example snippets


use Elephfront\RoboJsMinify\Task\Loader\LoadJsMinifyTasksTrait;

class RoboFile extends Tasks
{

    use LoadJsMinifyTasksTrait;
    
    public function minifyJs()
    {
        $this
            ->taskJsMinify([
                'assets/js/main.js' => 'assets/min/js/main.min.js',
                'assets/js/home.js' => 'assets/min/js/home.min.js',
            ])
            ->run();
    }
}

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

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

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

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