1 month ago

Laravel Mix and Tree Shaking JavaScript

Posted 1 month ago by thebigk

I'm curious to know if we need to explicitly enable tree shaking in Laravel Mix. Even with npm run prod, the size of my app.min.js is abou ~305 Kb!

I'm writing very minimal custom JS, and here''s all I'm using -

window.$ = window.jQuery = require('jquery');
window._ = require('lodash');
window.axios = require('axios');
import Echo from 'laravel-echo'; // I need this
window.Pusher = require('pusher-js');  // I need this

I think this is most of what Laravel uses. I was wondering if tree-shaking would bring the overall size down. Would appreciate suggestions / recommendations.

Please sign in or create an account to participate in this conversation.