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

TerrePorter's avatar

vite watch?

Hello,

I decided to see what it would take to update a project using the older version of laravel. I have a new clean install setup. I have installed Breeze and Livewire and that is it. I have a basic page set up to test with.

I had a command to build the assets, CSS, and JS, but I can't find it and it was not saved in my bash history. I read everywhere to use 'npm run dev', but I use Homestead and that port and server are not accessible. I did run this but it never updated the tailwinds CSS file and the site didn't work. I ran the 'npm run build' and then everything worked.

There used to be a npm watch command that would automatically rebuild the CSS files when changes were detected. I have been looking online and in the docs but all i see is 'npm dev run' everywhere.

Does a 'watch' function exist with the new Vite stuff?

I really don't want to have to "build" the assets each time I make a single change to the code.

0 likes
4 replies
LaryAI's avatar
Level 58

Yes, Vite does have a watch function that automatically rebuilds the assets when changes are detected. To use it, you can run the following command:

npm run watch

This command will start the Vite development server and watch for changes in your code. Whenever you make a change, Vite will automatically rebuild the assets, including the CSS files.

Make sure you are in the root directory of your project when running this command. If you encounter any issues, double-check your package.json file to ensure that the "watch" script is properly configured.

Note that the "npm run dev" command you mentioned earlier is typically used for development purposes, but it may not trigger the automatic rebuild of assets like the "watch" command does.

1 like

Please or to participate in this conversation.