# Frontend Asset Versioning

## Rule

Whenever a frontend asset is changed, the related library `version` in the owning `*.libraries.yml` file must also be incremented.

This is required to prevent browsers from keeping stale CSS or JS after deploys.

## Applies To

- custom modules in `web/modules/custom/*`
- custom themes in `web/themes/custom/*`

Examples:

- if `web/modules/custom/kaindl_catalog/js/kaindl-catalog-listing.js` changes, bump the related library version in [kaindl_catalog.libraries.yml](C:/Users/mihov1/Desktop/local-repos/kaindl/web/modules/custom/kaindl_catalog/kaindl_catalog.libraries.yml)
- if `web/themes/custom/kaindl_theme/css/megamenu.css` changes, bump the related library version in [kaindl_theme.libraries.yml](C:/Users/mihov1/Desktop/local-repos/kaindl/web/themes/custom/kaindl_theme/kaindl_theme.libraries.yml)

## What To Bump

Bump the version of the specific library that owns the edited asset.

Examples:

- `listing:` in `kaindl_catalog.libraries.yml`
- `components-navigation:` in `kaindl_theme.libraries.yml`
- `global-scripts:` in `kaindl_theme.libraries.yml`

Do not leave the version unchanged after editing CSS or JS that belongs to that library.

## Suggested Convention

Use a simple patch increment unless there is a reason to do more:

- `1.1.1` -> `1.1.2`
- `2.0.0` -> `2.0.1`

If multiple assets under the same library are changed in one task, bump the library version once.

## Practical Workflow

1. Edit the CSS / JS / library-owned frontend file.
2. Increment the matching library `version` in the relevant `*.libraries.yml`.
3. Deploy the changed files.
4. Clear Drupal caches on the server.
5. Hard-refresh the browser when verifying.

## Important Note

This should be treated as standard project hygiene for frontend work.

Future sessions should assume:

- asset changed
- library version bumped
- cache rebuild required
