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

jogesh_pi's avatar

Vite::asset() not working in blade template for laravel-modules

I am using laravel-modules package, When i try to use Vite::asset through the layout/master.blade.php then it works and looking to the relative manifest i.e. public/build-pages/. but it is not working to other blade templates.

My module structure is

  • /Modules/Pages/Resources/views/
  • /Modules/Pages/Resources/views/layouts/master.blade.php
  • /Modules/Pages/Resources/views/index.blade.php

Vite Configuration:

const dotenvExpand = require('dotenv-expand');
dotenvExpand(require('dotenv').config({ path: '../../.env'/*, debug: true*/}));

import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import path from 'path';

export default defineConfig({
    build: {
        outDir: '../../public/build-pages',
        emptyOutDir: true,
        manifest: true,
    },
    plugins: [
        laravel({
            publicDirectory: '../../public',
            buildDirectory: 'build-pages',
            input: [
                __dirname + '/Resources/assets/sass/app.scss',
                __dirname + '/Resources/assets/js/app.js'
            ],
            refresh: true,
        }),
    ],
    resolve: {
        alias: {
            '~bootstrap': path.resolve(__dirname, 'node_modules/bootstrap'),
        }
    },
});

Issue in file: - /Modules/Pages/Resources/views/index.blade.php

<img src="{{ Vite::asset('Resources/assets/images/xyz.svg') }}">

Error: Vite manifest not found at: /var/www/html/public/build/manifest.json because it is looking to wrong manifest that should be /var/www/html/public/build-pages/manifest.json

How do i fix this issue?

0 likes
1 reply
LaryAI's avatar
LaryAI
AI
Best Answer
Level 58

The issue is that the Vite::asset() function is looking for the manifest file in the wrong directory. To fix this, you need to specify the correct manifest path in your blade template.

In your index.blade.php file, change the Vite::asset() function to include the path to the manifest file:

<img src="{{ Vite::asset('Resources/assets/images/xyz.svg', 'build-pages') }}">

The second parameter of the Vite::asset() function specifies the directory where the manifest file is located. In this case, it is 'build-pages'.

This should resolve the issue and allow the Vite::asset() function to find the correct manifest file.

Please or to participate in this conversation.