M
M
Maxim Grechushnikov2014-11-24 17:24:16
Yii
Maxim Grechushnikov, 2014-11-24 17:24:16

Yii2, Assets: How to set it up correctly?

I want to take out, for example, the admin panel in a separate module. For the module, I assembled a separate layout and assets

<?php
/**
 * @link http://www.yiiframework.com/
 * @copyright Copyright (c) 2008 Yii Software LLC
 * @license http://www.yiiframework.com/license/
 */

namespace app\modules\admin\assets;

use yii\web\AssetBundle;

/**
 * author Qiang Xue <[email protected]>
 * @since 2.0
 */
class AppAsset extends AssetBundle
{
    public $sourcePath = '@app/modules/admin/assets/static';

    public $css = [
        'stylesheets/admin.css',
    ];
    public $js = [
    ];
    public $depends = [
        'yii\web\YiiAsset',
    ];
}

in the layout usually
use app\modules\admin\assets\AppAsset;

AppAsset::register($this);

But there are 2 troubles.
1. files are copied only once. What did I forget to include?
2. how can you selectively publish files? Layout in scss and it seems to me that scss files do not need to be copied from the folder

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Grechushnikov, 2014-11-24
@maxyc_webber

public $publishOptions = [
    'forceCopy' => true
];

Apparently missed

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question