Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel mix - Versioning does not work

I'm working on a fresh project using Laravel 5.6 using [email protected]. When I compile my assets using npm run production, they are not suffixed like they should

Note

Even when removing the if mix.inProduction() the versioning does not work

Questions

Am I the only facing this issue ? What should I do ?

webpack.mix.js

let mix = require('laravel-mix');
mix.js('resources/assets/js/app.js', 'public/js')
 .sass('resources/assets/sass/app.scss', 'public/css')
 .copyDirectory('resources/assets/images', 'public/images');

if (mix.inProduction()) {
  mix.version();
}
like image 291
Léo Coco Avatar asked Aug 26 '18 23:08

Léo Coco


1 Answers

Laravel 5.6's mix works differently now. Instead of suffixing your compiled files with hashes, it now uses a url query in trying to access your assets.

Try opening your browser dev tools and look at how your page includes your assets. It will append an id param in the URL.

e.g. GET /js/app.js?id=<SOME_HASH_HERE>

like image 157
Kenth John Israel Avatar answered Oct 11 '22 16:10

Kenth John Israel