There was a need to override the carousel.js carousel file from bootstrap . Content BootstrapAsset

Code: Select All

public $sourcePath = '@bower/bootstrap/dist'; public $css = [ 'css/bootstrap.css', ]; 

As you can see, BootstrapAsset refers to @bower/bootstrap/dist , and everything in the bootstrap.min.js file is in a heap. And I only need to override carousel.js in @bower/bootstrap/js . Tell me how to correctly override one file and point it to a link in BootstrapAsset , so as not to affect the rest?

    1 answer 1

    The AssetManager component has a $ bundles property with which you can customize the set of files included in the AssetBundle .

    For example, for BootstrapPluginAsset, instead of js/bootstrap.js you can specify the path to another, your own assembly of Bootstrap plugins (for example, if you use Gulp , Grunt or Webpack for this purpose), or specify separate paths to files for each of the plugins used. It is important to keep in mind that all the paths to css and js files are relative to $ sourcePath , so if your files are outside of this directory, then it will also need to be changed. For example, the configuration of the assetManager component in the config/web.php could look like this:

     'components' => [ 'assetManager' => [ 'bundles' => [ 'yii\bootstrap\BootstrapPluginAsset' => [ 'sourcePath' => '@bower/path/to/custom/bootstrap', 'js' => [ 'custom-bootstrap.js' ] ] ] ], ... ]