Cms: AssetBundle doesn't get re-published when contents change

Created on 11 Feb 2017  Â·  1Comment  Â·  Source: craftcms/cms

Description

When files inside the published directory for an AssetBundle changes, Craft doesn't re-publish the package to /web/cpresources.

Steps to reproduce

  1. Add an AssetBundle class to the root directory of the plugin (plugin/src/MyAwesomeBundle.php)
  2. Create a JS file (plugin/src/resources/js/file.js)
  3. Publish the source path (@ns/plugin/resources) and the JS file (js/file.js) in the AssetBundle class
  4. Confirm that the contents of the resources directory is published to web/cpresources
  5. Change the contents of the file plugin/src/resources/js/file.js
  6. Refresh browser, confirm that the contents of resources directory has not been re-published

Additional info

  • Craft version: 3.0.0-beta.3
  • PHP version: 7.0.14
  • Database driver & version: MySQL 5.6.34
  • Plugins & versions: None, except my custom plugin

Note: This is running locally using Laravel Valet 2.0.3. The web directory is symlinked to public, which might be relevant.

Note 2: Deleting the published folder manually _does_ make Craft re-publish the bundle.

bug

Most helpful comment

This should be fixed now.

For the curious / future-me: Yii only re-publishes asset bundles when the root directory’s modification time changes (https://github.com/yiisoft/yii2/issues/8197). We had extended that in Craft to also check any sub-directories’ modification times, however we’re finding that there are cases when a directory’s modification time does not get updated even if one of its sub-files gets updated. So this latest fix is to check all sub-files in addition to sub-directories to get the latest modification time.

>All comments

This should be fixed now.

For the curious / future-me: Yii only re-publishes asset bundles when the root directory’s modification time changes (https://github.com/yiisoft/yii2/issues/8197). We had extended that in Craft to also check any sub-directories’ modification times, however we’re finding that there are cases when a directory’s modification time does not get updated even if one of its sub-files gets updated. So this latest fix is to check all sub-files in addition to sub-directories to get the latest modification time.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

leigeber picture leigeber  Â·  3Comments

angrybrad picture angrybrad  Â·  3Comments

angrybrad picture angrybrad  Â·  3Comments

mccombs picture mccombs  Â·  3Comments

angrybrad picture angrybrad  Â·  3Comments