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

simondavies's avatar

New Laravel vite and tailwind CSS build issue

So started a new Laravel project and so thought give this Vite a go, before taking all out and putting Mix back in.

So just wanted the base Laravel project (No Vue, react, Inertia etc), just laravel and also Tailwind CSS.

Got it all working nicely and running, but then decided to try to see what the build version is like so run

npm run build

All went well until i then refreshed the browser, then then page just hangs with the Chrome Tab loading circle. Looked in the network tab and it was showing 'client, app.js and app.css' as pending...

As i write this is it still trying to load the page.

The page is a very stripped down page with 'Lorem' copy and one image and a few tailwind classes to test, so the page and classes used aren't heavy at all.

I am using local development via Laravel Valet.

Tried the trusted google search but they all reference vue, react set ups etc, and nothing really relating to this issue.

vite.config.js

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

export default defineConfig({
    plugins: [
        laravel([
            'resources/css/app.css',
            'resources/js/app.js',
        ]),
    ],
});

postcss.config.js

module.exports = {
    plugins: {
      'postcss-import': {},
      tailwindcss: {},
      autoprefixer: {},
    },
  }

tailwind.config.js

const defaultTheme = require('tailwindcss/defaultTheme');

module.exports = {
    content: [
        './storage/framework/views/*.php',
        './resources/views/**/*.blade.php',
        './resources/js/**/*.js',
    ],
    theme: {
        extend: {
			
        },
    },

    plugins: [require('@tailwindcss/forms')],
};

In my layout page

@vite(['resources/css/app.css', 'resources/js/app.js'])
0 likes
8 replies
simondavies's avatar

Ok After being able to spend a little more time on this...

Using Safari and the network tag, this showed that the Client, CSS and JS files where trying to load the assets from localhost where as the site loaded using the test domain.

Anyways I tried a couple of things and what got it to run for me it once I have complete npm run dev and want to run the build production I had to close my terminal (hyper) tab and open a new window.

Then cd in to the site again and run the build script and then the site loaded fine.

Looking then in the Safari network tab, i notice that this time all files loaded from the test domain? So not sure where to go from here at the moment, other than creating a new hyper window to run my builds ?

eugenefvdm's avatar

Thanks for documenting your experience. Where did you get this line?

 'postcss-import': {},
thinkverse's avatar

The Vite client should only be loaded if you started the Vite development server with npm run dev, then the @vite blade directive will try and load assets from Vite's local development server.

If you build with npm run build then the @vite directive will load the build manifest.json and load assets from public/build.

Sounds like you had the development server running and maybe the public/hot file didn't get removed when you closed the server?

From what I can tell, when starting the Vite development server, a file called hot is created in /public that stores the URL of the Vite development server, and it the @vite directive finds that it's present, it'll try and load assets from that. Could it be that file is still present in your /public folder? And the directive is trying to load from the development client but cannot connect since the server isn't running?

6 likes
chmoris's avatar

@thinkverse That solved the problem for me! I have to delete hot file from public folder, after I run "npm run dev" and "npm run build", to make the css work.

1 like
PT-83's avatar

@thinkverse thanks so much! Removing the hot file and rebuilding... I feel like it's such a common occurrence it probably should be mentioned in the tailwind installation docs when using the Laravel framework install..

simondavies's avatar

thanks @thinkverse for the response i revert to Mix for now so will check within my next project, or if / when I switch back 👌 @eugenevdm cannot remember at mo, will let you know when i do

1 like

Please or to participate in this conversation.