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

tszyuloveyou's avatar

Vite manifest not found at:....../public/build/manifest.json but the manifest.json builded in ....../public/build/.vite/manifest.json

When I running npm run dev that it is work but when I shop the npm run dev and run the npm run build after the running complete that go to the web site, I get the error message "Illuminate\Foundation\ViteManifestNotFoundException: Vite manifest not found at: ....../public/build/manifest.json in ....../vendor/laravel/framework/src/Illuminate/Foundation/Vite.php:934"(...is the project root path). npm run build build the manifest.json in ....../public/build/.vite, not in in ....../public/build/

I also has been post on stact overflow: https://stackoverflow.com/posts/79744695/edit

package.json

{
    "private": true,
    "type": "module",
    "scripts": {
        "build": "vite build && vite build --ssr",
        "dev": "vite && vite --ssr"
    },
    "devDependencies": {
        "autoprefixer": "^10.4.20",
        "axios": "^1.7.4",
        "concurrently": "^9.0.1",
        "laravel-vite-plugin": "^1.0",
        "postcss": "^8.4.47",
        "sass": "^1.77.6",
        "tailwindcss": "^3.4.13",
        "vite": "^6.0"
    },
    "dependencies": {
        "@fortawesome/fontawesome-free": "^6.7.2",
        "@inertiajs/svelte": "^2.0.12",
        "@sveltejs/vite-plugin-svelte": "^5.0.3",
        "@sveltestrap/sveltestrap": "^7.1.0",
        "bootstrap": "^5.3.3",
        "bootstrap-icons": "^1.11.3",
        "ckeditor5": "^44.1.0",
        "glob": "^11.0.3",
        "svelte": "^5.34.1",
        "svelte-dnd-action": "^0.9.64"
    }
}

vite.config.js

import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import { svelte } from '@sveltejs/vite-plugin-svelte';
import path from 'path';
import { globSync } from 'glob';

export default defineConfig({
    build: { manifest: true },
    plugins: [
        laravel({
			input: [
                'resources/css/app.scss', 'resources/js/app.js',
                'resources/js/clearInputHistory.js',
                'resources/js/submitForm.svelte.js',
                'resources/js/timeZoneDatetime.js',
                ...globSync("resources/js/Pages/**/*.svelte")
            ],
            ssr: 'resources/js/ssr.js',
            refresh: true,
        }),
        svelte(),
    ],
    resolve: {
        alias: {
            '@': path.resolve(__dirname, 'resources/js'),
            '~': path.resolve(__dirname, 'node_modules'),
            '^': path.resolve(__dirname, 'public'),
        },
    },
});

resources/js/app.js

import './bootstrap';
import bootstrap from 'bootstrap/js/index.umd';
import { Styles } from '@sveltestrap/sveltestrap';
import { createInertiaApp } from '@inertiajs/svelte';
import { hydrate, mount } from 'svelte';
import Layout from "@/Pages/Layouts/App.svelte";

// fix multiple levels of nested dropdowns do not collapse when the parent of the current expanded level is clicked
// source form: https://jsfiddle.net/dallaslu/mvk4uhzL/
(
    function($bs) {
        const CLASS_NAME = 'has-child-dropdown-show';
        $bs.Dropdown.prototype.toggle = function(_orginal) {
            return function() {
                document.querySelectorAll(
                    '.' + CLASS_NAME).forEach(function(e) {
                        e.classList.remove(CLASS_NAME);
                    }
                );
                let dd = this._element.closest('.dropdown').parentNode.closest('.dropdown');
                for (; dd && dd !== document; dd = dd.parentNode.closest('.dropdown')) {
                    dd.classList.add(CLASS_NAME);
                }
                return _orginal.call(this);
            }
        }($bs.Dropdown.prototype.toggle);

        document.querySelectorAll('.dropdown').forEach(
            function(dd) {
                dd.addEventListener('hide.bs.dropdown', function(e) {
                    if (this.classList.contains(CLASS_NAME)) {
                        this.classList.remove(CLASS_NAME);
                        e.preventDefault();
                    }
                    e.stopPropagation(); // do not need pop in multi level mode
                });
            }
        );

        // for hover
        document.querySelectorAll('.dropdown-hover, .dropdown-hover-all .dropdown').forEach(
            function(dd) {
                dd.addEventListener('mouseenter', function(e) {
                    let toggle = e.target.querySelector(':scope>[data-bs-toggle="dropdown"]');
                    if (!toggle.classList.contains('show')) {
                        $bs.Dropdown.getOrCreateInstance(toggle).toggle();
                        dd.classList.add(CLASS_NAME);
                        $bs.Dropdown.clearMenus();
                    }
                }
            );
            dd.addEventListener(
                'mouseleave', function(e) {
                    let toggle = e.target.querySelector(':scope>[data-bs-toggle="dropdown"]');
                    if (toggle.classList.contains('show')) {
                        $bs.Dropdown.getOrCreateInstance(toggle).toggle();
                    }
                }
            );
        });
    }
)(bootstrap);

// add ucfirst php function to js
Object.defineProperty(String.prototype, 'ucfirst', {
    value: function() {
        return this.charAt(0).toUpperCase() + this.slice(1);
    },
    enumerable: false
});

// add range php function to js
window.range = function(start, stop, step = 1) {
    return Array.from({ length: (stop - start) / step + 1 }, (_, index) => start + index * step);
}

Date.prototype.addYear = function() {
    var date = new Date(this.valueOf());
    date.setFullYear(date.getFullYear() + 1);
    return date;
}

Date.prototype.addYears = function(years) {
    var date = new Date(this.valueOf());
    date.setFullYear(date.getFullYear() + years);
    return date;
}

Date.prototype.subYear = function() {
    var date = new Date(this.valueOf());
    date.setFullYear(date.getFullYear() - 1);
    return date;
}

Date.prototype.subYears = function(years) {
    var date = new Date(this.valueOf());
    date.setFullYear(date.getFullYear() - years);
    return date;
}

Date.prototype.addMonth = function() {
    var date = new Date(this.valueOf());
    date.setMonth(date.getMonth() + 1);
    return date;
}

Date.prototype.addMonths = function(months) {
    var date = new Date(this.valueOf());
    date.setMonth(date.getMonth() + months);
    return date;
}

Date.prototype.subMonth = function() {
    var date = new Date(this.valueOf());
    date.setMonth(date.getMonth() - 1);
    return date;
}

Date.prototype.subMonths = function(months) {
    var date = new Date(this.valueOf());
    date.setMonth(date.getMonth() - months);
    return date;
}

Date.prototype.startOfMonth = function(days) {
    var date = new Date(this.valueOf());
    date.setDate(1);
    return date;
}

Date.prototype.endOfMonth = function(days) {
    var date = new Date(this.valueOf());
    date.setDate(new Date(date.getFullYear, date.getMonth + 1, 0).getDate());
    return date;
}

Date.prototype.addDay = function() {
    var date = new Date(this.valueOf());
    date.setDate(date.getDate() + 1);
    return date;
}

Date.prototype.addDays = function(days) {
    var date = new Date(this.valueOf());
    date.setDate(date.getDate() + days);
    return date;
}

Date.prototype.subDay = function() {
    var date = new Date(this.valueOf());
    date.setDate(date.getDate() - 1);
    return date;
}

Date.prototype.subDays = function(days) {
    var date = new Date(this.valueOf());
    date.setDate(date.getDate() - days);
    return date;
}

Date.prototype.startOfDay = function(days) {
    var date = new Date(this.valueOf());
    date.setHours(0, 0, 0, 0);
    return date;
}

Date.prototype.endOfDay = function(days) {
    var date = new Date(this.valueOf());
    date.setHours(23, 59, 59, 999);
    return date;
}

Date.prototype.addHour = function() {
    var date = new Date(this.valueOf());
    date.setHours(date.getHours() + 1);
    return date;
}

Date.prototype.addHours = function(hours) {
    var date = new Date(this.valueOf());
    date.setHours(date.getHours() + hours);
    return date;
}

Date.prototype.subHour = function() {
    var date = new Date(this.valueOf());
    date.setHours(date.getHours() - 1);
    return date;
}

Date.prototype.subHours = function(hours) {
    var date = new Date(this.valueOf());
    date.setHours(date.getHours() - hours);
    return date;
}

createInertiaApp({
	resolve: (name) => {
		const pages = import.meta.glob("./Pages/**/*.svelte", { eager: true });
		let page = pages[`./Pages/${name}.svelte`];
		return { default: page.default, layout: page.layout || Layout };
	},
	setup({ el, App, props }) {
        if (el.dataset.serverRendered === 'true') {
            hydrate(App, { target: el, props })
        } else {
            mount(App, { target: el, props })
        }
	},
});

config/inertia.php

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Server Side Rendering
    |--------------------------------------------------------------------------
    |
    | These options configures if and how Inertia uses Server Side Rendering
    | to pre-render the initial visits made to your application's pages.
    |
    | You can specify a custom SSR bundle path, or omit it to let Inertia
    | try and automatically detect it for you.
    |
    | Do note that enabling these options will NOT automatically make SSR work,
    | as a separate rendering service needs to be available. To learn more,
    | please visit https://inertiajs.com/server-side-rendering
    |
    */

    'ssr' => [

        'enabled' => (bool) env('INERTIA_SSR_ENABLED', true),

        'url' => env('INERTIA_SSR_URL', 'http://127.0.0.1:13714'),

        // 'bundle' => base_path('bootstrap/ssr/ssr.mjs'),

    ],

    /*
    |--------------------------------------------------------------------------
    | Testing
    |--------------------------------------------------------------------------
    |
    | The values described here are used to locate Inertia components on the
    | filesystem. For instance, when using `assertInertia`, the assertion
    | attempts to locate the component as a file relative to any of the
    | paths AND with any of the extensions specified here.
    |
    */

    'testing' => [

        'ensure_pages_exist' => true,

        'page_paths' => [

            resource_path('js/Pages'),

        ],

        'page_extensions' => [

            'js',
            'jsx',
            'svelte',
            'ts',
            'tsx',
            'vue',

        ],

    ],

    'history' => [

        'encrypt' => (bool) env('INERTIA_ENCRYPT_HISTORY', false),

    ],

];
0 likes
2 replies

Please or to participate in this conversation.