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:clearandphp artisan view:clearCleared browser cache
Confirmed that
manifest.jsonon the server contains the new hash filenamesConfirmed 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?
npm run buildlocally then rsyncing, or are you doing that command on the remote host?