Are there any way of including files from different folders in an assetbundle?
For example, lets say i am creating an assetbundle and this bungle include css and js from a folder "vendor/bower/myplugin/myjsfile.js" and "vendor/bower/myplugin/mycssfile.css". But then i have some default config in another jsfile under "web/js" which should also be part of the asset. How do we tackle this?
<?php
namespace frontend\assets;
use yii\web\AssetBundle;
class MyTestAsset extends AssetBundle
{
public $sourcePath = '@bower/myplugin';
public $css = [
'myplugin.min.css'
];
public $js = [
'myplugin.min.js',
// myconfig.js - this file is found under web/js
];
public $depends = [
'yii\bootstrap\BootstrapAsset',
];
}
I believe that most "proper" way to do this would be to override AssetBundle::registerAssetFiles():
class MyTestAsset extends AssetBundle
{
...
public function registerAssetFiles($view)
{
parent::registerAssetFiles($view);
$view->registerJsFile('@web/js/your-file.js');
}
}