Answer the question
In order to leave comments, you need to log in
How to create your own Asset class for a separate module?
Hello! I am writing a module and I want to create my own Asset class for it (let it be called RbacAsset).
How can I make css and js (other) files attached to the layout?
<?php
namespace app\modules\rbac\assets;
class RbacAsset extends \yii\web\AssetBundle
{
public $basePath = '@rbac';
public $baseUrl = '@rbac';
public $css = [
'css/tailwind.css'
];
}
<?php
$params = require __DIR__ . '/params.php';
$db = require __DIR__ . '/db.php';
$config = [
'id' => 'basic',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'aliases' => [
'@bower' => '@vendor/bower-asset',
'@npm' => '@vendor/npm-asset',
'@rbac' => '@app/rbac/web'
],
'modules' => [
'rbac' => [
'class' => 'app\modules\rbac\Module',
],
],
Answer the question
In order to leave comments, you need to log in
In the desired layout / view, connect the assets you need:
use app\modules\rbac\assets\RbacAsset;
RbacAsset::register($this);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question