https://github.com/elfsundae/laravel-asset-version
Laravel static assets versioning via query string: "app.js" → "app.js?d41d8cd98f"
https://github.com/elfsundae/laravel-asset-version
Last synced: 7 months ago
JSON representation
Laravel static assets versioning via query string: "app.js" → "app.js?d41d8cd98f"
- Host: GitHub
- URL: https://github.com/elfsundae/laravel-asset-version
- Owner: ElfSundae
- License: mit
- Created: 2017-11-22T07:29:44.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-03T17:37:49.000Z (over 8 years ago)
- Last Synced: 2025-03-22T08:02:45.508Z (over 1 year ago)
- Language: PHP
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Laravel Asset Version
[](https://packagist.org/packages/elfsundae/laravel-asset-version)
[](LICENSE.md)
[](https://styleci.io/repos/111650758)
Laravel static assets versioning via query string: `app.js` → `app.js?d41d8cd98f`.
## Installation
```sh
$ composer require elfsundae/laravel-asset-version
```
For Lumen or earlier Laravel than v5.5, you need to register the service provider manually:
```php
ElfSundae\Laravel\AssetVersion\AssetVersionServiceProvider::class,
```
## Configuration
First you need to create an asset version configuration file located at `config/asset-version.php` , filled with assets paths. Or you may run the `asset-version:update` artisan command to create this file:
```php
'3ede8f2085',
'js/app.js' => '2eaf111399',
'images/foo.png' => 'd41d8cd98f',
);
```
:warning: **You need to run the `asset-version:update` command every time you changed any asset content.** You may call this command in your assets build script, e.g. [Laravel Elixir](https://laravel.com/docs/5.3/elixir):
```js
elixir((mix) => {
mix.sass('app.scss')
.webpack('app.js')
.exec('php artisan asset-version:update');
});
```
> For Laravel Elixir, you can use [`laravel-elixir-asset-version`](https://github.com/ElfSundae/laravel-elixir-asset-version) NPM package to easily execute update.
## Usage
You can get the versioned asset path using the `asset_path()` helper function:
```php
asset_path('css/app.css'); // "/css/app.css?3ede8f2085"
```
## License
This package is open-sourced software licensed under the [MIT License](LICENSE.md).