PHP code example of nsrosenqvist / phulp-assetic

1. Go to this page and download the library: Download nsrosenqvist/phulp-assetic 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/ */

    

nsrosenqvist / phulp-assetic example snippets




use NSRosenqvist\Phulp\Assetic;

$phulp->task('styles', function ($phulp) {
    $phulp->src(['assets/styles/'], '/scss$/')
        ->pipe(new Assetic([
            new \Assetic\Filter\ScssphpFilter,
            new \Assetic\Filter\CssMinFilter,
        ], 'theme.css')) // <!---
        ->pipe($phulp->dest('dist/styles/'));
});



use NSRosenqvist\Phulp\Assetic;

$phulp->src(['assets/images/'], '/jpg$/')
    ->pipe(new Assetic((function() {
        if ($bin_path = shell_exec('which jpegoptim') ?: false) {
            $jpegoptim = new \Assetic\Filter\JpegoptimFilter($bin_path);
            $jpegoptim->setMax(85);
            return $jpegoptim;
        }
      })()))
      ->pipe($phulp->dest('dist/images/'));
});