Have a look at code splitting which is a webpack feature. There is a good explanation using Laravel Mix here
May 12, 2020
9
Level 5
use laravel-mix to create more then one js mix
I have the following scenario:
I have 2 views product.blade.php and checkout.blade.php (a product page and a checkout page)
In the package.json I will install all the vue modules and what is needed for all the pages ( product and checkout)
I want to have 2 different app.js with different logic and vue modules loaded: one for product and one for checkout. I want to be able to run dev or compile for production separately and import them in the blade files:
in product.blade.php
<script src="{{ mix('/js/product.js') }}"></script>
and in the checkout.blade.php
<script src="{{ mix('/js/checkout.js') }}"></script>
Every page has different modules loaded and different logic. I don't one big app.js to load all the logic and modules for all the pages.
It is possible to use laravel-mix to work like I want?
Please or to participate in this conversation.