You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was still struggling to make it work, and have had to make some modifications to get to a walking skeleton of CSS reloading:
Add some subfolders of app/assets/stylesheets to css_paths
Add scss to css_extensions
Monkey patch Hotwire::Spark::Change#canonical_changed_path to always return "/application.css" when action == :reload_css.
The first two points was necessary for any events to get fired in the first place, as my CSS is mainly defined in scss files in subfolders of app/assets/stylesheets, imported in app/assets/stylesheets/application.scss. Part 3 was to get application.css reloaded, in stead of the constituent file that was actually modified.
Is there something I've misunderstood here? If not, perhaps some additions could be made to streamline this a bit π€
The text was updated successfully, but these errors were encountered:
I don't think you misunderstood! Currently, there's only basic support for Sprockets, meaning it simply doesn't raise an error if you're using Sprockets. There's no support for sass/scss/coffeescript right now. I think this would also be kind of hard to add in a non-buggy way, without parsing sass imports.
If you don't want to monkey patch, you could also try the following instead:
Change the reload method to :replace, since this will also reload the <head> if there are changes
Add the scss extension and paths to the html_paths and html_extensions, which will then trigger an :replace reload if a scss file is changed
This will not do a fine-grained css reload, but a full Turbo visit instead, but maybe this is good enough for your use case.
Ah, nice to know about an alternative approach. The monkey patching is working at the moment, but now I have somewhere to go if/when it causes me too much pain. π Thanks again!
Thanks for making this! π€© We're still running sprockets, so it was nice to see #41 adding basic sprockets support β thanks for that @codergeek121!
I was still struggling to make it work, and have had to make some modifications to get to a walking skeleton of CSS reloading:
app/assets/stylesheets
tocss_paths
scss
tocss_extensions
Hotwire::Spark::Change#canonical_changed_path
to always return "/application.css" whenaction == :reload_css
.The first two points was necessary for any events to get fired in the first place, as my CSS is mainly defined in scss files in subfolders of
app/assets/stylesheets
, imported inapp/assets/stylesheets/application.scss
. Part 3 was to getapplication.css
reloaded, in stead of the constituent file that was actually modified.Is there something I've misunderstood here? If not, perhaps some additions could be made to streamline this a bit π€
The text was updated successfully, but these errors were encountered: