Hi friend did you find any solution to this?
How can I make Vite split dependencies into a vendor file per entry point without manually writing them? Kinda like Mix.
I'm trying to make it behave similar to what I had in Mix. This is my setup:
import laravel from 'laravel-vite-plugin';
export default {
plugins: [
laravel({
input: [
'resources/css/admin.css',
'resources/css/public.css',
'resources/js/admin.js',
'resources/js/public.js'
],
refresh: true,
})
]
};
If I add splitVendorChunkPlugin, I get one vendor file which contains all dependencies in admin.js and public.js. Is there a way to have each entry point automatically create its own vendor file? So when admin.js is called, it imports something like vendor-admin.js which contains dependencies found in admin.js while public.js will import vendor-public.js which contains dependencies found in public.js.
In other words, I have:
- admin.js, which imports
axiosandhighlight.js. - public.js, which imports
vueandjszip.
Vite, with splitVendorChunkPlugin, does this:
- vendor.js, which contains,
axios,highlight.js,vueandjszip. - admin.js
- public.js
What I want:
- vendor-admin.js, which contains
axiosandhighlight.js. - admin.js
- vendor-public.js, which contains
vueandjszip. - public.js
The exact filenames or folder structure is not super important to me, as long as everything gets resolved when requested.
I've read about manualChunks but my understanding is, I'd have to write every dependency in vite.config.js, right?
Please or to participate in this conversation.