elminson/css-js-versioning

This package generate a css and js versioning based on the commit hash

v1.2.0 2024-01-20 02:38 UTC

This package is auto-updated.

Last update: 2024-09-20 04:35:23 UTC


README

This package performs versioning of the css files.

Installation

composer require elminson/css-js-versioning

After install execute

composer run post-install-cmd

This command will install the pre-commit file on .git folder

How to use it

in your core html template load the version

<?php
$cssVersion = file_get_contents("css_version");
$jsVersion = file_get_contents("js_version");
?>


#implementation in all your css link href
<link href="<?=base_url();?>css/app.css?v=<?=$cssVersion?>" rel="stylesheet">
<link href="<?=base_url();?>css/morestyles.css?v=<?=$cssVersion?>" rel="stylesheet">

#implementation in all your js file
<script src="js/index.js?v=<?=$jsVersion?>"></script>

...

### No css or js changes

running local test

$ php -S localhost:8000 -t tests/