laravel-mix: Versioning not working at all

When I run .version() under dev … the app.js file isn’t created, so that’s broke.

When I run it under production, Laravel doesn’t read the manifest for some reason and tries to deliver app.css and app.js which aren’t found.

Perhaps I need to change my Envoyer set up?

Right now I use npm run dev in my local environment, and I have Envoyer hooks on my production server to install node modules and run Mix in production.

Do I need to change the flow of my deployments or is this going to get fixed so that it works as it did in version 5?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 19 (2 by maintainers)

Most upvoted comments

For anyone still coming to this thread: As of version 1.0

File versioning has been simplified. When using mix.version(), no longer will we version the file name, itself. Instead, we’ll generate an md5 of the file’s contents, and apply it as a query string to the generated mix-manifest.json file. If using a service like Cloudflare, please ensure that you’ve enabled querystring-based cache-busting.

So don’t expect to have versioned files created. You’ll just have your app.js, main.css, etc. Query strings will be referenced in the manifest file that will handle the cache busting.

Concerning squid, from version 2.7, they no longer have the obsolete rule of not caching when query strings are used. I don’t know of any services on which query strings don’t work for cache busting. There are some services which require you to explicitly set that option though.

Mix File

let mix = require('laravel-mix')

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

Response

Mix Manifest

{
    "/js/app.js": "/js/app.js?id=92b261429d3aa1b907b2",
    "/css/app.css": "/css/app.css?id=b9cb5c393f3dcc0fb457"
}