WSL2 Livereload
I’m a very happy user of WSL2, it’s blazing fast and allows me to fiddle with projects that I otherwise would have issues with running on my Windows machine. I’m also a user of hugo, to create static homepages.
I was trying to figure out how to use sass and to pre-process those files into css using hugo’s built in pipes. I was scratching my head and cursing for a good while, trying to understand why the pipes where not working. Turns out that it wasn’t anything wrong with the pipes, it was the environment where I ran hugo.. 🤦♂️
Setup
- WSL2
- Hugo
- Project located on the Windows filesystem
Problem
Changing a file on the Windows filesystem does not trigger a notification that a file has changed to WSL2, this means that livereload will not work in hugo since no change has been detected.
Solutions
- Move your project into your WSL2 directory and work from there
- File change notifications are working for WSL1, this is what I choose
Further reading
People have been writing quite extensivly regarding this, but it seems to be a feature and not a bug according to Microsoft.
https://github.com/microsoft/WSL/issues/4739
Update
I decided to retire my old WSL1 setup, and by doing so it forced my to embrace the filesystem of WSL2. It’s working out for me, even though I was a bit skeptical about putting the project on the WSL2 mount.