Giter VIP home page Giter VIP logo

laravel-asset-version's Introduction

Laravel Asset Version

Latest Version on Packagist Software License StyleCI

Laravel static assets versioning via query string: app.jsapp.js?d41d8cd98f.

Installation

$ composer require elfsundae/laravel-asset-version

For Lumen or earlier Laravel than v5.5, you need to register the service provider manually:

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

return [
    'css/app.css',
    'js/app.js',
    'images/foo.png',
];

Then you can run the asset-version:update command to update the asset version configuration:

$ php artisan asset-version:update

Now the configuration file might be:

<?php

return array (
  'css/app.css' => '3ede8f2085',
  'js/app.js' => '2eaf111399',
  'images/foo.png' => 'd41d8cd98f',
);

⚠️ 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:

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 NPM package to easily execute update.

Usage

You can get the versioned asset path using the asset_path() helper function:

asset_path('css/app.css');  // "/css/app.css?3ede8f2085"

<link href="{{ asset_path('js/app.js') }}" rel="stylesheet">

License

This package is open-sourced software licensed under the MIT License.

laravel-asset-version's People

Contributors

elfsundae avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.