O
O
Oleg2018-09-28 16:18:24
Yii
Oleg, 2018-09-28 16:18:24

Yii2 basic: why is timestamp not added for resources from web folder?

Good afternoon, dear YII experts. Created a set:

class AppAsset extends AssetBundle
{
    public $basePath = '@webroot';
    public $baseUrl = '@web';

    public $css = [
       '/css/style.css',
    ];
   
    public $depends = [
        'yii\web\YiiAsset',
        'yii\bootstrap\BootstrapPluginAsset',
    ];
}

In the settings config/web.php specified:
'components' => [
   'assetManager' => [
            'appendTimestamp' => true,
   ],
]

and the link to the style file is formed without a timestamp: although for resources from plug-ins, a timestamp is added.
<link href="/css/style.css" rel="stylesheet">

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2018-09-28
@volego

Good afternoon.
Remove the first slash in '/css/style.css',
ps And, as Arik recommends , include the file in the layouts of the application if it is not included.
In main.php

use app\assets\AppAsset;
AppAsset::register($this);

A
Arman, 2018-09-28
@Arik

you need to connect the file as asset , and not specify it in the template.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question