Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/incenteev/hashed-asset-bundle
Apply an asset version based on a hash of the asset for symfony/asset
https://github.com/incenteev/hashed-asset-bundle
assets bundle cache-busting hacktoberfest php symfony symfony-bundle
Last synced: 2 months ago
JSON representation
Apply an asset version based on a hash of the asset for symfony/asset
- Host: GitHub
- URL: https://github.com/incenteev/hashed-asset-bundle
- Owner: Incenteev
- License: mit
- Created: 2017-02-17T15:56:20.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2024-01-16T13:30:11.000Z (11 months ago)
- Last Synced: 2024-04-26T01:03:54.239Z (8 months ago)
- Topics: assets, bundle, cache-busting, hacktoberfest, php, symfony, symfony-bundle
- Language: PHP
- Homepage:
- Size: 53.7 KB
- Stars: 23
- Watchers: 4
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
HashedAssetBundle
=================The HashedAssetBundle provides an asset version strategy which uses a hash
of the file content as asset version. This allows bumping the asset version
separately for each asset (automatically).[![CI](https://github.com/Incenteev/hashed-asset-bundle/actions/workflows/ci.yml/badge.svg)](https://github.com/Incenteev/hashed-asset-bundle/actions/workflows/ci.yml) [![Total Downloads](https://poser.pugx.org/incenteev/hashed-asset-bundle/downloads.svg)](https://packagist.org/packages/incenteev/hashed-asset-bundle) [![Latest Stable Version](https://poser.pugx.org/incenteev/hashed-asset-bundle/v/stable.svg)](https://packagist.org/packages/incenteev/hashed-asset-bundle)
## Installation
Use [Composer](https://getcomposer.org) to install the bundle:
```bash
$ composer require incenteev/hashed-asset-bundle
```## Usage
Register the bundle in the kernel:
```php
// app/AppKernel.php// ...
class AppKernel extends Kernel {
public function registerBundles()
{
$bundles = array(
// ...
new Incenteev\HashedAssetBundle\IncenteevHashedAssetBundle(),
);
}
}
```Then configure FrameworkBundle to use the new version strategy:
```yaml
framework:
assets:
version_strategy: incenteev_hashed_asset.strategy
```## Advanced configuration
The default configuration should fit common needs, but the bundle exposes
a few configuration settings in case you need them:```yaml
incenteev_hashed_asset:
# Absolute path to the folder in which assets can be found
# Note: in case you apply a base_path in your asset package, it is not
# yet applied to the string received by the bundle
web_root: '%kernel.project_dir%/web'
# Format used to apply the version. This is equivalent to the
# `framework > assets > version_format` of the static version strategy
# of FrameworkBundle.
version_format: '%%s?%%s'
```## License
This bundle is under the [MIT license](LICENSE).
## Alternative projects
If you want to apply cache busting by renaming files in your asset pipeline
(for instance with the webpack-encore versioning feature), have a look at the
`json_manifest` strategy available in Symfony itself.## Reporting an issue or a feature request
Issues and feature requests are tracked in the [Github issue tracker](https://github.com/Incenteev/hashed-asset-bundle/issues).