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

Therin's avatar

Laravel 9 Vite not updating tailwind changes

Hello Recently started a fresh new laravel project and noticed that mix got replaced with vite. Now i have everything setup with vite, i also added Tailwind CSS and Alpine JS.

The issue is that when i run the "npm run dev" command, it all works and pages also reload automatically (using purely blade files), but when i change a tailwind class like a background to another color, the page refreshes and i can see in the page source that the class has changed, but visually it reverts back to default color.

When i go to inspect the element the new background color class is also not to be found in the styles list.

Am i missing something somewhere? I have no idea where to look atm.

0 likes
24 replies
Therin's avatar

@Snapey Any other suggestions? As i mention below i do keep the command running.

Therin's avatar

Yes i am, i'm on Windows so i have a git bash terminal open to keep php artisan serve running, and another to keep npm run dev running. I also made the adjustements from freek, which are linked in the thread you linked, but i haven't done the addition of the watch command, as it shouldn't have to be needed?

Snapey's avatar

when you update a blade file, do you see activity in the vite window?

Therin's avatar

@Snapey I don't see any activity in the vite window when i update & save a blade file.

Sinnbeck's avatar

Show your vite config and tailwind config

bljdavidson's avatar

I had a similar issue. Make sure you have updated the content array in your Tailwind config to match the new file types:

// tailwind.config.js
module.exports = {
    content: ['./resources/**/*.blade.php', './resources/**/*.js', './resources/**/*.tsx'],
    ....
    ....

You will also need to make sure you have postcss and autoprefixer installed through NPM. You will also need a postcss.config.js file:

// postcss.config.js
module.exports = {
    plugins: {
        tailwindcss: {},
        autoprefixer: {},
    },
};

Hope this helps,

Ben

2 likes
Therin's avatar

@bljdavidson I reviewed my files and tested this with the original laravel welcome page.

If i add the path './resources/**/*.blade.php' to the tailwind config, the welcome.blade page updates as it should.

The problem is that my blade view files are in another location: './app/Directory/Directory/Resources/views/Directory/*.blade.php' with many different Directories like this: ./app/Directory/xxx/Resources/views/xxx/*.blade.php

How do i add this to the tailwind config file?

Currently i added, as with the previous mix plugin, ./app/Directory/**/*.blade.php' but that doesn't seem to work for vite.

My current tailwind.config.js file:

/** @type {import('tailwindcss').Config} */
module.exports = {
    content: [
        './app/Directory/**/*.blade.php',
        './resources/**/*.js',
        './resources/**/*.blade.php',
    ],
    darkMode: 'media',
    theme: {
        extend: {
        },
    },
    plugins: [],
}
Therin's avatar

@bljdavidson nvm, i found my mistake.

i have to add this to the tailwind config: './app/**/*.blade.php'

Not entirely sure why it doesn't allow './app/Directory/**/*.blade.php'

bljdavidson's avatar
Level 14

@Therin Ah Vite will only work with one nested directory; any more, it will unfortunately break.

So ./app/nested/*.blade.php will work. However ./app/nested/nested/*.blade.php won't work. It's the same when using React or Vue with dynamic imports.

I hope that helps. If my comment has helped, please could you mark it as the best answer so it can help others :)

2 likes
Sinnbeck's avatar

@Therin why do you have blade files inside your app directory? And is the folder just named Directory? Can you give the actual name if it isn't so people can replicate it?

'./app/Directory/**/*.blade.php',
Therin's avatar

@Sinnbeck I have blade files inside my app directory because, as i'm still on this learning journey (only been learning since 6-10 months ago), i am trying out different things. So for my new "project" i am trying to incorporate "modules"?.

For example my current project will have several modules that can be set to active or inactive and it will run or drop migrations, register a service provider if active, etc. Some modules are like a ticketing system, inventory management, asset management, etc ...

So my folder structure is actually more like this, where it concerns the blade files:

./app/Project/Tickets/Resources/views/tickets/*.blade.php
./app/Project/Inventory/Resources/views/inventory/*.blade.php

So a lot of different directories, which represent the modules, with deeper nested blade files.

So when i added

./app/Project/**/*.blade.php

to the tailwind.config.js file, thinking it would cover all nested locations starting from ./app/Project/ it didn't seem to work. It only started working once i omitted the /Project/ part so it looked like above ./app/**/*.blade.php

Sinnbeck's avatar

@Therin ok that's interesting. It should work with that path. I wonder if it is having problems due to the casing of Project. Are you on windows?

Therin's avatar

@Sinnbeck Not sure which part you find interesting :)

I had other "projects" with similar directory structures when Laravel installations were still using Mix and running the npm run watch command, so i thought it would be the same when a newly installed project came with Vite.

I am on Windows yes, not running anything like Homestead, i am just using the php artisan serve function to run the projects.

Sinnbeck's avatar

@Therin it's interesting that I haven't seen anything like this before. I have helped quite alot of people with both vite and tailwind, and you are the first one with this problem. I will do some thinking/testing

2 likes
Sinnbeck's avatar

@Therin just noticed that all of your folders has an s at the end. Any chance that the folder is named Projects not Project?

Therin's avatar

@Sinnbeck Not all of them have an s at the end (well 90% do, but still).

I am following the directory structure that somewhat resembles the normal Laravel structure. Normally blade files are stored in './resources/views' so it follows that, which is also showcased where i first read about a modular approach: https://nwidart.com/laravel-modules/v6/introduction

So './app/Project' is the only constant (and without an s at the end) where all the modules are bundled, the other subdirectories are just the different modules, each with their own directory structured as in the page i linked.

Sinnbeck's avatar

@bljdavidson yeah that's interesting indeed. But I have way deeper nesting and have had zero issue. But good find :)

Sinnbeck's avatar

Sorry for the delay. I just created a brand new project, and make a structure like yours in my app directory. I added a view and gave it some classes. I then compiled with npm run build and checked the css file it output. And the classes was in there as expected. So sadly I cannot recreate the problem

Therin's avatar

@Sinnbeck I think i may have found the issue (a silly oversight of myself perhaps), but it's specific to the command npm run dev.

Directory structure is indeed the way i've been writing it here with the uppercase letter:

app/Project/

If i write the directory all in lowercase within tailwind.config.js:

app/project/**/*.blade.php

Then the command npm run dev will 'build' once but offer no further updates when i save a blade file.

The command npm run build will 'build' everything correctly (as far as i can tell, every npm run build i run after a blade file save when adjusting classes seems to update correctly in the browser).

If i write the directory as it is within tailwind.config.js (so uppercase):

app/Project/**/*.blade.php

Then the command npm run dev will 'build' once and will show subsequent update info in the terminal window on every blade save.

So my silly oversight was that i typed it in lowercase in one project, which didn't seem to be an issue for Mix when that was used in other projects.

Please or to participate in this conversation.