On a fresh install, when I run npm run production, mix will not update the hash on app.js. The hash that is written appears not to change even though the file being compiled has changed.
npm run production to create initial mix-manifestif (mix.inProduction()) { mix.version(); }npm run productionnpm run productionCould not reproduce.
Are you making significant changes in app.js ?
@ankurk91 No, the changes were not extensive. Sample app js:
require('./bootstrap');
window.Vue = require('vue');
Vue.component('example-component', require('./components/ExampleComponent.vue'));
const app = new Vue({
el: '#app'
});
var test='test';
var test2='test';
var test3='testing';
var testFuncton = function(){
console.log('Test function');
}
It appears that the simple variables/functions I add at the bottom of the file do not trigger a hash update.
HOWEVER, I did notice that if I put them in a separate file and imported them (e.g. import './test.js'), it triggered a hash change.
Also, if I remove the Vue component or comment out the app const, the hash gets updated.
Curious if webpack/mix is smart enough to realize you're in production mode and those are unused variables and an unused function. Maybe it strips and ignores?
From what I gather it doesn't do webpack style hashing on JS files declared in your mix file when running npm run prod. Instead, it'll add an ?id= for each recognized asset in the mix file in the manifest.json. When using the mix() blade function, it'll take the file within the argument and find the respective entry in the manifest and then use that entry as the asset file.
If you you really want to add your own webpack style hashing on your JS, you will have to override the webpack config entry point to use [name].[yourhashofchoice].js
@ikudosi Thanks for your feedback. I'm going to close the issue as it's not really affecting me at the moment, and it doesn't seem like anyone else has noticed it.
I have this problem too. Is this all right now?
@heimuya My solution was to move notable changes to external files.
Most helpful comment
From what I gather it doesn't do webpack style hashing on JS files declared in your mix file when running
npm run prod. Instead, it'll add an?id=for each recognized asset in the mix file in the manifest.json. When using the mix() blade function, it'll take the file within the argument and find the respective entry in the manifest and then use that entry as the asset file.If you you really want to add your own webpack style hashing on your JS, you will have to override the webpack config entry point to use [name].[yourhashofchoice].js