Last active
May 5, 2025 17:50
-
-
Save james2doyle/3aa8d1802db63cca84858bda9bd61e39 to your computer and use it in GitHub Desktop.
Use the Vite facade in Laravel to version the assets with a query string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// version the asset path for each deploy | |
Vite::createAssetPathsUsing(function (string $path): string { | |
return cache()->rememberForever($path, function () use ($path) { | |
// "z" is "day of the year" so this value will only change on the day of deployment | |
return sprintf('%s?v=%s', asset($path), date('z')); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment