Reputation: 1950
Using Laravel 5.4 and Mix, when I run npm run watch
it compiles everything once and looks like it is waiting for changes, but when I make changes to any of my asset files it doesn't seem to detect anything. Is there a solution?
Upvotes: 30
Views: 50570
Reputation: 192
Use:
npm run watch-poll
It's working on Ubuntu as well. And it is auto compiling on code changes.
Upvotes: 13
Reputation: 5617
I prefer to use inotify-tools. To install this tool set, run this command:
sudo apt install inotify-tools -y
sudo yum -y install inotify-tools
Then for big folders, run:
sudo sysctl fs.inotify.max_user_watches=500000000
Finally, run this command to watch folder changes:
while true; do npm run dev; inotifywait -e modify,create,delete,move -r resources/ ; done
You can limit the target watching directory (resources/ in this example) for better performance.
Upvotes: 1
Reputation: 2007
I was using mix.scripts
which doesn't actually compile your scripts, just copies them, so there is no npm readout on a compilation, because it's not compiling anything. If you aren't using mix.js
or mix.sass
(r any of the other compilers in your webpack.mix.js
file then npm run watch
will appear to do nothing because it is just copying in the background.
Upvotes: 0
Reputation: 540
npm run watch-poll
watch-poll
periodically checks (polls) for changes e.g. every 1000ms it will manually check to see if any files have changed.
what laravel
docs say?
You may find that in certain environments Webpack isn't updating when your files change. If this is the case on your system, consider using the watch-poll command. You can read up on the docs for a more information about mix.
Upvotes: 5
Reputation: 1950
The solution was provided by Jeffrey Way over at Laracasts.
Try adding the --watch-poll flag to your package.json
script. Or just try:
node_modules/.bin/webpack --watch --watch-poll --config=node_modules/laravel-mix/setup/webpack.config.js
Upvotes: 40