D
D
Daniil Sidorov2018-03-15 15:50:22
Yii
Daniil Sidorov, 2018-03-15 15:50:22

How to make dependencies in Asset yii2?

Hello, I connect on the PageAsset page

<?php

namespace app\assets;

use yii\web\AssetBundle;

/**
 * Main application asset bundle.
 *
 * @author Qiang Xue <qiang.xue@gmail.com>
 * @since 2.0
 */
class PageAsset extends AssetBundle
{
    public $basePath = '@webroot';
    public $baseUrl = '@web';
    public $css = [
        '/web/page-asset/css/main.min.css',
    ];
    public $js = [
        '/web/page-asset/js/scripts.min.js',
        '/web/page-asset/js/common-main.js',
        '/web/page-asset/js/ajax.js',
    ];
    public $depends = [
          'yii\web\YiiAsset',
    ];
}

Jquery is in the scripts.min.js file (the file with all the compressed libraries). YiiAsset is registered in depends , but it is loaded before my file with jquery. How can I make YiiAsset connect after my libraries?
PS In YiiAsset, I removed the jquery connection
'assetManager' => [
            'bundles' => [
                'yii\web\JqueryAsset' => [
                    'js'=>[]
                ],
                'yii\bootstrap\BootstrapPluginAsset' => [
                    'js'=>[]
                ],
                'yii\bootstrap\BootstrapAsset' => [
                    'css' => [],
                ],
            ],
        ],

How to build the correct connection order? Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2018-03-15
@webinar

If some collector collects everything for you and you already have a minified file with everything, why do you need AssetsManager?
Remove it from depends, you specified a bunch of scripts and indicated that they are dependent on yii\web\YiiAsset, of course, the system connects the dependency to you earlier, and this makes sense.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question