Answer the question
In order to leave comments, you need to log in
Why doesn't appendTimestamp work for several AssetBundles, but it works for the rest?
Everything is written in the web.php file:
$config = [
....
'components' => [
'assetManager' => [
'appendTimestamp' => true
],
<?php
namespace app\assets;
use yii\web\AssetBundle;
class AdminAsset extends AssetBundle
{
public $css = [
'css/admin.css',
'css/icons.css',
];
public $js = [
'js/admin.js'
];
public $depends = [
'\yii\web\YiiAsset',
'\app\assets\BootstrapSwitchAsset',
'\app\assets\TizixBootstrapAsset',
'\app\assets\JqueryUIAsset',
'\app\assets\TinyMceAsset',
'\app\widget\uploader\assets\UploaderAssets',
];
<?php
namespace app\assets;
use yii\web\AssetBundle;
class AppAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $js = [
'js/admin.js',
];
public $depends = [
'\yii\web\YiiAsset'
];
Answer the question
In order to leave comments, you need to log in
Since the basePath and baseUrl properties are not set in AdminAsset, they are picked up from the corresponding properties of the resource manager. And in the resource manager, they are set to @webroot/assets and @web/assets respectively. You have the admin.js file in the @webroot/js/admin.js directory, and due to the unset properties of the resource kit, the manager looks for it along the path @webroot/assets/js/admin.js, which is why there are problems with AdminAsset. With AppAsset, such problems are not observed. You set the correct paths to the files in it
The problem was solved by adding:
public $basePath = '@webroot';
public $baseUrl = '@web';
Keep in mind the walkers - the paths must be without the first slash
, that is, this will work
public $js = [
'js/admin.js',
];
public $js = [
'/js/admin.js',
];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question