stebal's avatar
Level 1

Laravel + Vite manifest output

Long time without Laravel (I'm FE dev). now I'm making a webapp with Laravavel, React and Vite.

When I make: ddev npm run build, vite outputs the manifest in /public/.vite/manifest.json, but then when I browse the page, I have a message saying that laravel does not find the public/manifest.json.

does anybody already have this ?

0 likes
5 replies
Nakov's avatar

What you shared above is two different locations:

output: /public/.vite/manifest.json

error: public/manifest.json

so why it is outputting the manifest in the wrong directory?

when you open the package.json file do you have this:

"scripts": {
    "dev": "vite",
    "build": "vite build"
},
stebal's avatar
Level 1

hey thanks for your anser. Yes i know it's two different locations, that's exactly the problem.

Yes, my package. json has

"scripts": {
        "build": "vite build",
        "dev": "vite"
    },

and I event tried to force the output of the manifest in vite.config.js, but it does not care... Here is my vite.config.js, maybe something is wrong, I'm way more used to Webpak, so Vite is still in "discover" mode.

dogma's avatar
dogma
Best Answer
Level 1

You can set the manifest.json path manually by creating a vite.php file in you app/config

<?php


return [
    /*
    |--------------------------------------------------------------------------
    | Default Build Path
    |--------------------------------------------------------------------------
    |
    | Dies ist der Standardpfad, an dem Laravel nach dem Manifest sucht.
    | Du kannst hier ein benutzerdefiniertes Verzeichnis für dein Manifest
    | angeben, z. B. für getrennte SSR- oder User-Builds.
    |
    */
    'build_path' => env('VITE_BUILD_PATH', 'build/*'),
];


in your case that would probably be: "public/.vite/"

exxsy's avatar

Hello, if you set manifest: true in vite.config.mjs it creates the manifest into the ".vite" folder, if you just delete that property from config it does actually create the manifest to the directly build directory.

Please or to participate in this conversation.