1

I’m using Laravel + React + Vite, deployed on shared hosting. The problem is that Laravel keeps referencing old build files (e.g. old hash names in public/build/assets) even after I run npm run build again.

For example, after running a new build locally, my public/build folder looks like this:

public/build/
  assets/
  manifest.json

I uploaded the new files to the hosting (replaced the entire public/build folder), but when I open the site in the browser, Laravel still tries to load the old hashed file name (for example app-Xyz123.css) which no longer exists.

This results in a 404 error for missing CSS/JS files.

Here’s my setup:

vite.config.js

import { wayfinder } from '@laravel/vite-plugin-wayfinder';
import tailwindcss from '@tailwindcss/vite';
import react from '@vitejs/plugin-react';
import laravel from 'laravel-vite-plugin';
import { defineConfig } from 'vite';

export default defineConfig({
    plugins: [
        laravel({
            input: ['resources/css/app.css', 'resources/js/app.tsx'],
            ssr: 'resources/js/ssr.tsx',
            refresh: true,
        }),
        react(),
        tailwindcss(),
        wayfinder({
            formVariants: true,
        }),
    ],
    esbuild: {
        jsx: 'automatic',
    },
});

Environment

APP_ENV=production
APP_DEBUG=false

What I’ve tried:

  • Deleted and re-uploaded public/build completely

  • Ran php artisan optimize:clear and php artisan view:clear

  • Cleared browser cache

  • Confirmed that manifest.json on the server contains the new hash filenames

  • Confirmed correct permissions (755)

But Laravel is still outputting the old asset paths from the previous build in the rendered HTML.

'hot' files are not in my public folder

Why does Laravel keep referencing the old build files even though I’ve replaced the entire public/build directory with a fresh build?

Is there some caching mechanism or configuration I need to clear so Laravel will read the new manifest.json?

2
  • Are you doing the npm run build locally then rsyncing, or are you doing that command on the remote host? Commented Oct 26 at 18:06
  • Why does Laravel keep referencing the old build files: just to dig into this a bit, are you sure this is Laravel? The 404s would be coming from your web server. (I agree though that the URLs containing build hashes will be served by a Laravel template...). It might be worth trying a different browser, so you can be doubly sure that browser page caching is not to blame. Commented Oct 26 at 18:09

1 Answer 1

0

Answer:

I found the issue.
It wasn’t a cache or CDN problem. The mistake was on my side.

After building with Vite, I only uploaded the new manifest.json file to public_html/build/,
but Laravel actually reads it from project_root/public/build/manifest.json.

On my shared hosting (Rumahweb), the public_html folder is mapped to Laravel’s public directory,
so the correct manifest file must be inside project/public/build/manifest.json.

Once I uploaded the correct manifest.json to that location and cleared Laravel caches with:

php artisan optimize:clear

everything worked fine.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.