Search code examples
laravellaravel-elixirlaravel-mix

Benefit of using the newer Laravel Mix over Elixir


Since Laravel 5.4, the default method to compile assets is using Laravel Mix, instead of elixir.

I know that "Mix" uses WebPack by default to compile the assets.

What benefits does this method bring?


Solution

  • The Mix also allows you to compile without WebPack, and this always produces files that are smaller in size and work the same.

    This is entirely incorrect. Have you attempted to configure any of the myriad options to optimize your bundle at all?

    Start with the webpack-bundle-analyzer plugin. This will give you an idea where your bloat is, what is duplicated, and where to start trimming your application.

    Between uglifying, chunking, deduplification, minification, etc. you'll have in the end compiled resources that are far from "large".

    Now I'll grant you it has a steep learning curve comparative to other tools, regardless, WebPack is an incredibly powerful tool, you need to take the time to learn it's configuration capabilities.

    Care to elaborate on what you mean by working the same? I run several production applications as well as a number of smaller personal projects. I never seem to get different results after each build.

    But in the end it's just a tool. A tool like any other tool, you use what you feel comfortable with and what fits for the job. There's a reason it as selected as the default, though. And it isn't because the maintainers are ignorant by any means.