I have a path something like /actions/users/someaction in the frontend and I want to use the Bootstrap-Asset (located in /backend/web/assets/xxxxxx/) from the backend.
So I created an asset called "ActionAsset" with following content:
class ActionAsset extends AssetBundle
{
public $basePath = '@backend';
public $baseUrl = '@web/backend';
public $css = [
'css/external.css',
'css/overwrite-bootstrap.css',
];
public $js = [
];
public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap\BackendBootstrapAsset',
];
}
The included css are just working fine, but the dependencies are always saved in /frontend/web/assets/. My question is (and I really searched for weeks) how to change this location to /backend/web/assets.
You need to define
$sourcePath
. Yii2 AssetManager will copy (or symlink) your assets in your current web/assets/ folder.From the docs
So change your code to:
Or: Just overwrite your asstetbundle in
@frontend/asset
and set$sourcePath
property accordingly: