question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

mix.version() is not working (no hashes are added in mix-manifest.json)

See original GitHub issue
  • Laravel Mix Version: 1.4.2
  • Node Version (node -v): v6.10.3
  • NPM Version (npm -v): 3.10.10
  • OS: Centos + MacOS

Description:

mix.version() is not generating hashed URL’s for my assets

Steps To Reproduce:

in my webpack.mix.js I have:

if (mix.inProduction()) {
    console.log("We are in production");
    mix.version(['public/js/app.js', 'public/css/app.css']);
}

the console log gets triggered just fine, but there are no hashes appended to my stylesheet or js file, which I’m loading in my views like so:

<link href="{{ mix('css/app.css') }}" rel="stylesheet"> the output is the following without cache busting: <link href="/css/app.css" rel="stylesheet">

the mix-manifest.json file looks like this

{
    "/js/app.js": "/js/app.js",
    "/css/app.css": "/css/app.css",
    "/js/app.js.map": "/js/app.js.map",
    "/css/app.css.map": "/css/app.css.map"
}

UPDATE: this seems to be working locally on my machine, but not on my CentOS server. I’ve set permissions to 777 on the mix-manifest.json file, but that doesn’t solve the issue. I’m thinking this might be permission related? Are there any other files that mix needs to be able to write to while running the build in order to update the mix-manifest file?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:10
  • Comments:27

github_iconTop GitHub Comments

18reactions
allentcmcommented, Feb 19, 2018

I found out that the mix configuration parameter “inProduction” has been rename to “production”. I’m using the below code for versioning.

if (mix.config.production) {
    mix.version();
}

The final JS file with hash mappings are stored in the mix-manifest.json file.

9reactions
panzer-planetcommented, Oct 11, 2019

I was really stuck here for a while. If nothing above seems to work, it’s possible you’ve made the same mistake I did. Make sure you are calling mix and not asset when you include your script. Good: <script src="{{ mix('js/app.js') }}" defer></script> Bad: <script src="{{ asset('js/app.js') }}" defer></script>

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - mix.version() is not working (no hashes are added in ...
UPDATE: this seems to be working locally on my machine, but not on my CentOS server. I've set permissions to 777 on the...
Read more >
Versioning | Laravel Mix Documentation
version() method to enable file hashing, such as app.js?id=8e5c48eadbfdd5458ec6 . This is useful for cache-busting purposes. // 1. Version all compiled assets.
Read more >
mix.version() does not make the files - Laracasts
The files get appended with a hash at the end, so it doesn't create new files for you it just adds the hash...
Read more >
The Mix manifest does not exist when it does exist
I had same exception after deployment laravel project to server. It was working perfectly fine on localhost but after lot of research I ......
Read more >
Create a mix-manifest.json file with esbuild | stefanzweifel.io
I've been using Mix just for one feature: versioning. By adding .version() to my configuration file, Laravel Mix would create a mix-manifest.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found