AssetCompress\Shell\Task\AssetBuildTask::_buildTarget PHP Method

_buildTarget() protected method

Generate and save the cached file for a build target.
protected _buildTarget ( AssetTarget $build ) : void
$build MiniAsset\AssetTarget The build to generate.
return void
    protected function _buildTarget(AssetTarget $build)
    {
        $writer = $this->factory->writer();
        $compiler = $this->factory->compiler();
        $name = $writer->buildFileName($build);
        if ($writer->isFresh($build) && empty($this->params['force'])) {
            $this->out('<info>Skip building</info> ' . $name . ' existing file is still fresh.');
            return;
        }
        $writer->invalidate($build);
        $name = $writer->buildFileName($build);
        try {
            $this->out('<success>Saving file</success> for ' . $name);
            $contents = $compiler->generate($build);
            $writer->write($build, $contents);
        } catch (Exception $e) {
            $this->err('Error: ' . $e->getMessage());
        }
    }