yiisoft / yii2

Yii 2: The Fast, Secure and Professional PHP Framework
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
14.23k stars 6.91k forks source link

AssetConverter & Asset Manager doesn't update assets after changing sources #17620

Open speker2010 opened 4 years ago

speker2010 commented 4 years ago

What steps will reproduce the problem?

Create AssetBundle with scss source; Config scss compilation in AssetConverter; Publish resources once; Change scss; Nothing happend;

What is the expected result?

After change sources Its should update css file.

What do you get instead?

Nothing change in css

Additional info

It's check filemtime for 2 files before converting. For example assets/{hash}/main.css and assets/{hash}/main.scss. https://github.com/yiisoft/yii2/blob/09eacd8dc1120113032976099fd07290a4d37cd3/framework/web/AssetConverter.php#L68

But! It's check only !is_dir and forceCopy option before publish. Maybe it's should compare filemtime for source *.scss file and published *.scss file. https://github.com/yiisoft/yii2/blob/09eacd8dc1120113032976099fd07290a4d37cd3/framework/web/AssetManager.php#L545

Q A
Yii version 2.0.27-dev
PHP version PHP 7.1.26-1+ubuntu14.04.1+deb.sury.org+1
Operating system ubuntu14.04.1
samdark commented 4 years ago

Adjusting computation of last modification time may affect performance for the cases when there are many asset files in the directory.

samdark commented 4 years ago

But the issue overall makes sense to me.

radionovel commented 4 years ago

You can override $publishOptions from AssetBundle Try it in your asset bundle class:

class AppAsset extends AssetBundle { // .... public $publishOptions = [ 'forceCopy' => true ]; // .... }