Recently, I integrated the yii2-bootstrap4 extension into my yii2-advanced project and customized it using a Sass file named custom.css
.
After adding custom.css
to frontend/web/css
, I made modifications to frontend/assets/AppAsset.php
as shown below:
class AppAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
'css/custom.css',
'css/site.css',
];
public $js = [
];
public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap4\BootstrapAsset',
];
}
Although I achieved the desired outcome, I observed that the <head>...</head>
section of my pages now includes the following:
<link href="/yii2-advanced/frontend/web/assets/1758a11a/css/bootstrap.css" rel="stylesheet">
<link href="/yii2-advanced/frontend/web/css/custom.css" rel="stylesheet">
<link href="/yii2-advanced/frontend/web/css/site.css" rel="stylesheet"></head>
Furthermore:
[...]/css/bootstrap.css
still contains the original Bootstrap 4 css- Removing the first entry from the DOM (via Devtools) does not affect the web pages.
Queries
- Is this the recommended method for replacing the Bootstrap 4 css file in Yii2?
- Is there a way to prevent the loading of
[...]/css/bootstrap.css
?