Skip to content

feat(cache): add additional_caches config for custom asset cache paths#906

Open
Soner (shyim) wants to merge 2 commits intomainfrom
feat/additional-asset-caches
Open

feat(cache): add additional_caches config for custom asset cache paths#906
Soner (shyim) wants to merge 2 commits intomainfrom
feat/additional-asset-caches

Conversation

@shyim
Copy link
Member

Summary

  • Adds additional_caches config option under build.zip.assets in .shopware-extension.yml
  • Allows extensions to cache/restore custom output paths alongside standard admin/storefront assets
  • Custom source paths are included in content hashing for cache key generation
  • Validates that source_paths is required for each entry

Example config

build:
  zip:
    assets:
      additional_caches:
        - path: Resources/public/custom
          source_paths:
            - Resources/app/custom/src

Test plan

  • Verify config parsing with additional_caches entries
  • Verify validation rejects entries with empty source_paths
  • Test cache store/restore with custom paths enabled (SHOPWARE_CLI_EXPERIMENTAL_ASSET_CACHING=1)

Allow extensions to define custom paths for asset caching via
.shopware-extension.yml under build.zip.assets.additional_caches.
Copilot AI review requested due to automatic review settings March 10, 2026 07:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for caching/restoring additional custom asset output directories for extensions via a new build.zip.assets.additional_caches config option, integrating it into asset source discovery, cache-key hashing, and cache store/restore.

Changes:

  • Extend .shopware-extension.yml schema/config model with build.zip.assets.additional_caches entries.
  • Include additional_caches[].source_paths in asset content hashing to influence cache keys.
  • Store/restore extra cached folders alongside standard administration/storefront caches.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
shopware-extension-schema.json Adds schema definitions for build.zip.assets.additional_caches.
internal/extension/config.go Adds config structs for additional_caches and validates source_paths non-empty.
internal/extension/project.go Propagates additional_caches from extension config into discovered asset.Sources.
internal/extension/asset.go Converts extension config additional_caches into asset.AdditionalCache for sources.
internal/asset/source.go Extends asset.Source to carry AdditionalCaches and defines AdditionalCache type.
internal/extension/asset_config.go Incorporates source_paths from additional caches into GetContentHash() input collection and maps source caches into runtime config.
internal/extension/asset_cache.go Stores/restores additional cached folders and enables caching even when only additional_caches are present.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Replace sanitizeCacheKeySuffix with xxhash to avoid collisions
- Add path validation: reject absolute paths and paths escaping root
- Fix early return bug: admin cache miss no longer skips storefront/additional cache restore
- Use filepath.SkipDir for node_modules to skip entire subtree
- Add tests for validation, hash invalidation, and node_modules skipping
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants