how to use mix versioning in Laravel?

Viewed 740

after npm run prod for production in laravel, do I need to upload mix.manifest.json along app.css and app.js to shared hot or not? the mix.manifest.json file will change to :

{
    "/js/app.js": "/js/app.js?id=b891664151c01b268197",
    "/css/app.css": "/css/app.css?id=4b5a5b36ae9495db0146"
}

but no such files in public, uploading just app.css and app.js is enough?

and is my code correct for versioning in production and development?

mix.js('resources/js/app.js', 'public/js')
  .sass('resources/sass/app.scss', 'public/css')
  .version();

if (mix.inProduction()) {
  mix.version();
}

1 Answers

You will also have to copy mix.manifest.json to your public folder along with app.css and app.js. Mix.manifest.json is where Laravel looks to get the version number. You will also have to change how you grab your css and js files in your app.blade.php so it looks like this:

<link rel="stylesheet" href="{{ mix('css/app.css') }}">
Related