Vagrant doesn’t watch files edited in host

I've been stuck all day on a stupid problem: I set up a simple Vagrant box with Ubuntu 17.10 to use with Ionic

I've created a simple blank project with

$ Ionic new myproj blank

then I entered my /vagrant/myproj dir and launched

$ ionic serve.

At first I couldn't reach my app from my browser 'cause I forgot to forward ports from host to guest. 

So I added to my Vagrantfile this lines:

config.vm.network :forwarded_port, host: 8100, guest: 8100
config.vm.network :forwarded_port, host: 35729, guest: 35729

It worked: I were able to reach localhost:8100/myproject and see my app but... fuck

If I tried to edit my code, Ionic couldn't see the changes made to my proj. I must recompile it every time. Not too handy, in fact. 

So I googled (and "stackoverflowed") a lot since I found the solution. 

I must add this line to my Vagrantfile:

config.vm.synced_folder ".", "/vagrant", type: "rsync"

Then, after putting my box up with vagrant up (or vagrant reload) command, I must launch from another shell this command:

$ vagrant rsync-auto

in order to see my changes take effect

It worked like a charm.

HIH

You may also like

Leave a Reply

Your email address will not be published. Required fields are marked *