nickjj / docker-rails-example

A production ready example Rails app that's using Docker and Docker Compose.
MIT License
941 stars 185 forks source link

Changes to any JS or CSS file are not reflected and do not cause webpacker to reload #12

Closed MattStopa closed 3 years ago

MattStopa commented 3 years ago

I spent a few hours with this but as the title says, you can make changes to any JS or CSS file, but even after reloading the page the changes will not show up. For some reason Webpacker/Rails doesn't see a change as having happened.

nickjj commented 3 years ago

Hi,

Does webpack pick up the change in the terminal by showing an update after you change the file or does it show nothing?

What OS are you using?

MattStopa commented 3 years ago

Nope, webpacker definitely isn't picking up any change that I'm seeing. I'm on Windows, is that the problem maybe? I would figure it to be a nonissue since presumably, webpacker is looking at the Linux image it's running on rather than my local copy. That could be the issue though, some subtle difference between them?

nickjj commented 3 years ago

Are you using PowerShell or WSL / WSL 2?

MattStopa commented 3 years ago

I am using WSL 2

MattStopa commented 3 years ago

Correction: I do run WSL2 but I am actually using Powershell to run docker, I could try running it in WSL2 though, maybe that's worth a shot.

nickjj commented 3 years ago

Ah, ok next question: Do you have your files sitting on a drive that's mounted into WSL 2 through /mnt/c or do you have all of the files sitting within WSL 2's file system directly?

I have a feeling inotify events (the thing that triggers file changes) might not work if you have them mounted through Windows, but it does work if your files are in WSL 2 directly.

But more importantly it'll be SO much faster if your files are in WSL 2's file system (I use WSL 2 too for full time dev btw).

MattStopa commented 3 years ago

All the files are mounted through /mnt/c. I guess my question then would be, how would you put those files in the WSL 2 file system but also have access to them in windows, since obviously, you'll want to edit the files in a Windows-based editor.

nickjj commented 3 years ago

All of the files in WSL 2's file system are accessible through Windows by default.

You can open your WSL 2 terminal, clone down this repo and run cd ~/src/docker-rails-example or wherever you cloned the repo to and then run code . to open VSCode (or swap that with whatever you use). You could also run explorer.exe . to open the directory in Windows explorer and pin the directory to your quick access bar if you wanted.

MattStopa commented 3 years ago

Huh, wow. Okay I'll try to try it out today and get back to you to see if that is the issue. Thanks a bunch

MattStopa commented 3 years ago

Well, kind internet stranger. You have fixed my entire problem! After doing what you said I found that everything works great. I was pulling out my hair for so long trying to figure out why none of the rails example apps work, but after cloning in Ubuntu and rebuilding it worked fine.

Thanks so much for your help on this, I owe you one for sure.

nickjj commented 3 years ago

No problem. You may also want to watch these WSL 2 related videos too. They go over a few gotchas around WSL 2 and it taking up huge amounts of disk / memory usage without freeing those resources unless you do the things mentioned in the videos:

MattStopa commented 3 years ago

Sweet thanks I'll check them out