laravel-mix-versionhash icon indicating copy to clipboard operation
laravel-mix-versionhash copied to clipboard

Manifest not updating after reverting change

Open sevba opened this issue 5 years ago • 8 comments

I'm not sure this is an issue with laravel-mix-versionhash, as it could also be related to webpack watch.

I noticed that the manifest file isn't updating if you revert a change, while running "npm run watch".

Steps to reproduce:

  1. Run "npm run watch" to build your project and watch for changes
  2. Check the manifest file: /assets/js/app.3d89dd.js
  3. Make any random change to your source code and save. This triggers webpack-watch to re-build.
  4. Check the manifest file: /assets/js/app.a9b031.js - perfect, manifest is updated
  5. Undo the random change, i.e. revert back to the state of the code from step 1.
  6. Check the manifest file: /assets/js/app.a9b031.js - issue, should be updated back to the old hash from step 2!

If you check the modified date of /assets/js/app.3d89dd.js you'll see that it was touched. Also in the asset list shown by the "npm run watch" command, I see the file with the hash 3d89dd.

If I shut down "npm run watch" and start it again (i.e. trigger a full re-build of my code) then the manifest is properly updated.

sevba avatar May 03 '20 10:05 sevba

If I shut down "npm run watch" and start it again (i.e. trigger a full re-build of my code) then the manifest is properly updated.

u mean u get app.3d89dd.js back ?

ctf0 avatar May 03 '20 12:05 ctf0

If I shut down "npm run watch" and start it again (i.e. trigger a full re-build of my code) then the manifest is properly updated.

u mean u get app.3d89dd.js back ?

Exactly. So the problem only occurs when webpack watch is supposed to update the manifest. And only when you revert changes (i.e. when a file with the same hash was already built before).

I tried to delete the initial file (app.3d89dd.js) between step 4 and 5, to test if perhaps the issue occurs when webpack already finds an existing file (from an earlier build). This didn't fix it. So it appears that somehow webpack watch is still "aware" of earlier hashes.

Perhaps it caches earlier builds of modules and if it detects that there is actually nothing new (i.e. everything is already in its cache), it decides not to update the manifest?

sevba avatar May 03 '20 13:05 sevba

Because this seemed like an issue with webpack caching, I tried to reproduce with mix.webpackConfig({ cache: false }); however that didn't solve it, the problem persists.

sevba avatar May 03 '20 13:05 sevba

can u try with v1.0.8 of the plugin and reply back ?

ctf0 avatar May 03 '20 15:05 ctf0

can u try with v1.0.8 of the plugin and reply back ?

I just tried with v1.0.8 but the issue remains.

sevba avatar May 03 '20 17:05 sevba

does the hash change as expected with mix.version () ?

ctf0 avatar May 04 '20 09:05 ctf0

Yes, it works as expected with the regular mix.version() feature.

The reason why I prefer your plug-in over the mix.version() feature is because it actually hashes the filename. This supports my blue/green deployment setup. I deploy my assets (including the compiled JS files) to AWS S3. When I deploy, both the old version (blue) and the new version (green) exist in S3, so a rollback is very easy.

sevba avatar May 04 '20 19:05 sevba

@Erutan409 can u help with this?

ctf0 avatar May 05 '20 08:05 ctf0