tarngmyna's avatar

Create bundles with Laravel Mix

Hi.

I'm using Laravel Mix's vendor extracting feature to split my app and vendor code into separate files. The problem is I only get two files app.js and vendor.js. I'm using some modules (datatables.net for example) that only get used in a few pages and, with this setup, get included in every page load.

I know the browser should use internal caching and the huge vendor.js file should not be downloaded every time but there is also the parsing overhead for a library that is not used in most pages.

I would like to be able to build a datatables.js file that includes the library and app code and include it only in relevant pages. But with my mix setup:

mix.js('resources/js/app.js', 'public/js') .js('resources/js/datatables.js', 'public/js') .extract(); the datatables.js file is built successfully but the library still gets put in vendor.js.

Is there a way to accomplish this?

Thanks in advance.

0 likes
0 replies

Please or to participate in this conversation.