Yii2 disable asset of a vendor module

2019-02-25 10:00发布

问题:

I have installed yii2-admin module, located in /vendor/mdmsoft/yii2-admin but I don't want it to load its own asset bundle. It there any way to disable this module asset bundle?

回答1:

Yes, it's possible and even mentioned in official docs here. One way to do it is through application config:

return [
    // ...
    'components' => [
        'assetManager' => [
            'bundles' => [
                'mdm\admin\AdminAsset' => false,
            ],
        ],
    ],
];

Another way - during runtime through component:

\Yii::$app->assetManager->bundles['mdm\admin\AdminAsset'] = false;