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

sannjay's avatar

vite.config.js or config/vite.php?

I am coming back to Laravel development after long time. While reading about Vite configuration, I got confused with 2 config file options. In laravel documentation, it is suggested to use vite.config.js for all configuration set up. While on laravel-vite.innocenzi.dev site they refer to config/vite.php file.

Not sure which one to use?

0 likes
6 replies
drehimself's avatar
Level 35

The innocenzi/laravel-vite package is a 3rd party package that was the most popular way to use Laravel with Vite before the official one was released last week.

I think most people are now going to use the official plugin, as it is the default within new Laravel projects. In this case, your config would go in vite.config.js.

1 like
sannjay's avatar

@drehimself Thank you very much. I was not following the recent development. So landed in this confusion. One follow up question: there is no information about output directory configuration inside vite.config.js. By default it output in public/build/ directory I guess. Is it possible to set output directoy? Like public/dist/ ?

drehimself's avatar

@sannjay Try the build.outDir config option: https://vitejs.dev/config/#build-outdir

// vite.config.js
export default defineConfig({
    build: {
        outDir: './public/dist'
    },
    plugins: [
        laravel([
            'resources/js/app.js',
            'resources/css/app.css',
        ]),
    ],
});

Edit: This will build it in the folder specified but it won't work when trying to run the Laravel app. I guess it's looking for the public/build folder. I'm not sure if there's a way to configure this to work with Laravel.

3 likes
sannjay's avatar

@drehimself Ok, I will check and update later. Look like these are super new to Laravel and might have some problem. Once again thank you.

AlexRa's avatar

@drehimself If you want to use connection your files in Blade, try to use it

{{Vite::useBuildDirectory('dist')}}

@vite(['resources/css/app.css', 'resources/js/app.js'])

ugurcorek's avatar

Hi everyone, I am having the same problem. Can anyone help?

Please or to participate in this conversation.