Is there a way to get Yii2 to reload the module assets on each request?

My site is divided into separate modules. Each module has its own css or js files.
Yii assetManager creates a folder when I first open a page using my assets.

Unfortunately, if I change something in my files, Yii 1.x does not reload the css or js files.

I need to manually delete the web / assets folder. This is very annoying when you are developing an application.

This works when I add a module to the base folder, but not when I create a module in the provider folder with my own namespace.

+4
source share
3 answers

Yii1.x assetManager , forceCopy true

... , .

. forceCopy .

linkAssets, , . , .

, , Yii 2.x, AssetBundles, ,

use vendor\myVendorName\myPackageName\assets\AppAsset;
AppAsset::register($this);
+1

Yii2 URL- , ...

return [
    // ...
    'components' => [
        'assetManager' => [
            'appendTimestamp' => true,
        ],
    ],
];

, , , URL- - , .

+2

You can install forceCopy = true.

class Assets extends AssetBundle{

    public function init()
    {
        parent::init();
        $this->publishOptions['forceCopy'] = true;
    }
}
+2
source

All Articles