I'm using BrowserSync with Gulp to live reload a site in a local machine when specific kinds of files are changed. I've the following snippet in my gulpfile
:
gulp.task('browser-sync', function() {
browsersync.init({
proxy: "mySite:8080",
files: ["./*.html", "dev/*.css"]
});
});
When changing (and saving) any of the above kinds of files, I get an output like this in my terminal:
[BS] Serving files from: ./
[BS] Watching files...
[BS] File changed: index.html
[BS] File changed: dev\styles.css
All the while, the site reloads as expected, but its content does not reflect the changes that were made. I can't figure out what am I doing wrong here. Any hint appreciated!
UPDATE
I forgot to mention that my host machine is running Windows 10 and my guest machine is running Ubuntu 14.04.4 LTS. The VM provider is VirtualBox.
Initially, I was using the default config.vm.synced_folder
method. I had this on my vagrantfile
:
config.vm.synced_folder "/Path/To/My/Host/Website/Folder/", "/usr/nginx/html/mywebsite/"
I've since tried using NFS, with the following configuration:
config.vm.synced_folder "/Path/To/My/Host/Website/Folder/", "/usr/nginx/html/mywebsite/",
:type => :nfs,
:mount_options => ['nolock,vers=3,udp,noatime,actimeo=1']
Since my host is running Windows, I installed the plugin vagrant-winnfsd, which adds support for NFS. But now vagrant halts when it tries to mount the NFS shared folder.
In addition, since I was getting the following error on vagrant up
: GuestAdditions versions on your host (5.0.16) and guest (4.3.36) do not match
, I installed the plugin vagrant-vbgues, in order to keep VirtualBox Guest Additions up to date. At no avail either. Vagrant is still freezing when it tries to mount the NFS shared folder.
It so happens that the problem was related with VirtualBox, as explained here. Since I'm running Nginx on a virtual machine in VirtualBox, the solution to my problem was to comment out the
sendfile
directive innginx.conf
, or simply set it off, like this:The same issue is reported here, and here. As well as in the Vagrant docs, which state that "There is a VirtualBox bug related to
sendfile
which can result in corrupted or non-updating files."The title and the tags say you're using Vagrant, even though it's not mentioned in your question.
Make sure your changes are being synced to the VM. Have a look at the vagrant documentation to select the type of synced folders that will work for your situation. Their basic example is as follows:
You can
vagrant ssh
and check the files manually to make sure they match, and that the synced folders are working as expected.UPDATE
Based on the new information and comment, I would recommend using
rsync
as the shared folder method.I have never found a way to make NFS play well (and perform well) if Windows is in the mix.