yiisoft / yii2-bootstrap5

Yii 2 Bootstrap 5 Extension
https://www.yiiframework.com/
BSD 3-Clause "New" or "Revised" License
59 stars 37 forks source link

Missing css files while including `yii\bootstrap5\BootstrapPluginAsset` #59

Closed insthync closed 1 year ago

insthync commented 1 year ago

What steps will reproduce the problem?

Set $depends in AppAsset to

    public $depends = [
        'yii\web\YiiAsset',
        'yii\bootstrap5\BootstrapPluginAsset'
    ]

What is the expected result?

Having bootstrap css files in assets folder

What do you get instead?

No css files

Additional info

Q A
Yii vesion 2.0.45
PHP version 8.1.12
Operating system Windows 10
insthync commented 1 year ago

I've temporarily avoided this issue by following instructions in https://github.com/yiisoft/yii2-bootstrap5/blob/master/docs/guide/assets-setup.md -> Using CDN section

By add

        'assetManager' => [
            // override bundles to use CDN :
            'bundles' => [
                'yii\bootstrap5\BootstrapAsset' => [
                    'sourcePath' => null,
                    'baseUrl' => 'https://cdn.jsdelivr.net/npm/bootstrap@5.1/dist/',
                    'css' => [
                        'css/bootstrap.min.css'
                    ],
                ],
                'yii\bootstrap5\BootstrapPluginAsset' => [
                    'sourcePath' => null,
                    'baseUrl' => 'https://cdn.jsdelivr.net/npm/bootstrap@5.1/dist/',
                    'css' => [
                        'css/bootstrap.min.css'
                    ],
                    'js' => [
                        'js/bootstrap.bundle.min.js'
                    ],
                ],
            ],
        ],

to config/web.php (in components)

xhostch commented 1 year ago

Seems to be related to #9741, ran into the same issue just the other way around (js files not present).

You can also override the publishOptions in the application config to work around this:

        'assetManager' => [                                                                                                                                                           
            'bundles' => [
                'yii\bootstrap5\BootstrapAsset' => [                                                                                                                                  
                    'publishOptions' => ['only' => ['dist/js/bootstrap.bundle.*', 'dist/css/bootstrap.*']],                                                                                                                                           
                ],                                                                                                                                                                    
                'yii\bootstrap5\BootstrapPluginAsset' => [                                                                                                                            
                    'publishOptions' => ['only' => ['dist/js/bootstrap.bundle.*', 'dist/css/bootstrap.*']],
                ],                                                                                                                                                                    
            ],
        ],                                                                     
julianrutten commented 1 year ago

This is caused by #52. Best solution for now is to pin your dependency to version 2.0.3

simialbi commented 1 year ago

I think it's caused by the only clauses. Rolled back this change