Reputation: 365
I'm using a simple mix script to generate JS and CSS, but I have a question I haven't found the answer yet.
If I set the version() flag, will vendor.js be overwritten as well? If so, what are the advantages in production of using the extract method?
mix
.js('resources/assets/js/app.js', 'public/js')
.extract([
'lodash', 'jquery', 'vue', 'query-string',
'datatables.net', 'datatables.net-buttons', 'datatables.net-bs4', 'datatables.net-buttons-bs4', 'datatables.net-buttons/js/buttons.html5.js',
'select2', 'axios', 'moment', 'popper.js', 'bootstrap', 'vue-chartjs', 'v-tooltip', 'moment/locale/es', 'vue-moment',
'jszip/dist/jszip', 'pdfmake/build/pdfmake.js', 'pdfmake/build/vfs_fonts.js', 'sweetalert', 'vue-strap', 'vue-strap/dist/vue-strap-lang',
'moment-array-dates', 'vue-toast', 'randomcolor', 'url', 'google-maps'
])
.sass('resources/assets/sass/app.scss', 'public/css')
.copy('node_modules/font-awesome/fonts', 'public/fonts/vendor/font-awesome');
if (mix.inProduction()) {
mix.version();
}
Upvotes: 0
Views: 885
Reputation: 657
It's so that your frequently changed app.js file will utilize cache busting, but your rarely changed vendor.js files can be kept in cache for as long as possible.
A more detailed explanation comes from Jeffrey Way:
https://github.com/JeffreyWay/laravel-mix/blob/master/docs/extract.md
Upvotes: 1