Grunt watch detects file changes only after 5 seco

2020-02-23 08:05发布

Grunt watch (grunt-contrib-watch) is used to trigger reload of web app in browser. However, it is slow to notice file changes when running in a Vagrant virtual machine using NFS for synced folders. Changing a file triggers a reload only after about 5 seconds although it is expected to happen almost instantly. Why is grunt watch so slow to detect changes? Is there any way to make it faster?

With VirtualBox synced folders grunt watch detects file changes almost instantly. However, as VirtualBox synced folders are unacceptably slow for certain other operations on large amounts of files it is unfortunately not an option to revert back to it in this case.

1条回答
何必那么认真
2楼-- · 2020-02-23 08:51

Try these mount options in your Vagrantfile:

type: "nfs", mount_options: ['actimeo=1']

This will greatly reduce the NFS file attribute caching timeout. I was having similar troubles, seeing large delays with Vagrant/NFS when waiting for gulp and Django server reloads. This fixed it; file changes are now detected instantly.

查看更多
登录 后发表回答