The Assetic asset processor addon for phulp

1.0.1 2018-09-06 16:04 UTC

This package is auto-updated.

Last update: 2024-04-05 17:37:55 UTC


It's a third-party project that wraps Assetic so that you can take advantage of its file processing features in a Phulp pipe.


composer require nsrosenqvist/phulp-assetic



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')) // <!---

First argument is an array of all the filters you want to run on the files. If you pass a string as the second argument all the files will be concatenated and processed in one batch. If you omit the second argument then all filters will run on each file individually.

An easy way to add customize the filter instance is to create it in a self-executing function. Any element of the array that's not of the type \Asset\Filter\FilterInterface will be ignored.


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);
            return $jpegoptim;