Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

JohnRivs's avatar

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 axios and highlight.js.
  • public.js, which imports vue and jszip.

Vite, with splitVendorChunkPlugin, does this:

  • vendor.js, which contains, axios, highlight.js, vue and jszip.
  • admin.js
  • public.js

What I want:

  • vendor-admin.js, which contains axios and highlight.js.
  • admin.js
  • vendor-public.js, which contains vue and jszip.
  • 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?

0 likes
2 replies
nabinnmg's avatar

Hi friend did you find any solution to this?

Please or to participate in this conversation.