fkchang / opal-hot-reloader

Hot code reloading for Opal apps, includes React.rb support
MIT License
17 stars 8 forks source link

Does not reload CSS #7

Closed VinceG3 closed 7 years ago

VinceG3 commented 7 years ago

Hi, I'm using opal-hot-reloader with the latest github release, opal version 0.10.3, rails 5.0.2. I can't get it to actually reload the CSS in the browser. The console says Reloading CSS: app/assets/stylesheets/context_map.css but the new CSS does not show up in the browser, necessitating a page reload. Views and components work, it's just the styling that doesn't.

VinceG3 commented 7 years ago

I worked the issue down to OpalHotReloader::CssReloader#is_matching_stylesheet?

The Rails Asset Pipeline match isn't working. It's comparing href_base: context_map.self.css?body=1 with url_base: context_map

VinceG3 commented 7 years ago

Changing the regular expression on line 35 to /\.self-?.*.css.+/ fixes the problem. The old adage about using regular expressions gives you two problems and not just one comes to mind. Making a PR.