Asset file not copied

Hi there,

i’m trying to add font awesome as an asset, so i added it using composer.

I created a assets\FontAwesomeAsset.php class :


namespace app\assets;


use yii\web\AssetBundle;


class FontAwesomeAsset extends AssetBundle 

{

    public $sourcePath = '@bower/components-font-awesome'; 

    

    public $css = [ 

        'css/font-awesome.min.css', 

    ]; 

    

    public function init()

    {

        parent::init();

        $this->publishOptions['beforeCopy'] = function ($from, $to) {

            $dirname = basename(dirname($from));

            return $dirname === 'fonts' || $dirname === 'css';

        };

    }

}

i added it to the depends section of AppAsset :


public $depends = [

        'yii\web\YiiAsset',

        'yii\bootstrap\BootstrapAsset',

    	'yii\web\JqueryAsset',

    	'\app\assets\FontAwesomeAsset',

    ];

The file is well added to the head section :


<link href="/myapp/assets/123de986/css/font-awesome.min.css" rel="stylesheet">

but "/myapp/assets/123de986/" is empty…

any idea ?

Have you registered the asset bundle in your view?

Yes i added :




...

use app\assets\FontAwesomeAsset;

...

FontAwesomeAsset::register($this);

...