php - Including Frontend CSS file into Backend in Yii2 -


i'm trying include css file located in frontend/web/css backend main layout. working backend produce error frontend. frontend web url staging.example.com , backend web url backend.example.com.

<?php namespace frontend\assets; use yii\web\assetbundle;  class iconasset extends assetbundle {     public $sourcepath = '@frontend/web';     public $css = [         'css/icon.css',     ]; } ?> 

code inside frontend layout main.php

use frontend\assets\iconasset; iconasset::register($this); 

code inside backend layout main.php

use frontend\assets\iconasset; iconasset::register($this); 

you need create custom asset bundle in frontend follows

     namespace frontend\assets;      use yii\web\assetbundle;      use yii\web\yiiasset;          class customasset extends assetbundle{             public $basepath = '@webroot';             public $baseurl = '@web';             public $css = [                 'css/custom.css',                 'css/another_css.css'             ];         }` 

put above code in frontend web accessible folder , register asset bakend main layout file follows

use frontend\assets\customasset; use yii;  $bundle = customasset::register(yii::$app->view); 

Comments