The project is in a healthy, maintained state
Automatically reload Hotwire Turbo when app files are modified.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
 Dependencies

Runtime

>= 3.0.0
>= 6.0.0
 Project Readme

Hotwire::Livereload

Automatically reload Hotwire Turbo when "view" files are modified.

Hotwire__Livereload.Demo.1.mp4

Installation

The JavaScript for Hotwire::Livereload is installed via asset pipeline, which is included with this gem.

Add hotwire-livereload to your Gemfile:

bundle add hotwire-livereload --group development

Run installer:

rails livereload:install

Configuration

You can watch for changes in additional folders by adding them to listen_paths. For example, you can watch for CSS changes:

# config/environments/development.rb

Rails.application.configure do
  # ...
  config.hotwire_livereload.listen_paths << Rails.root.join("app/custom_folder")
end

Folders listened by default:

  • app/views
  • app/helpers
  • app/javascript
  • app/assets/stylesheets
  • app/assets/javascripts
  • app/assets/images
  • app/components
  • config/locales

You can setup force reloading (full page reload) for changes in some folders using force_reload_paths option. For example, you can trigger force reload on JS changes:

# config/environments/development.rb

Rails.application.configure do
  # ...
  config.hotwire_livereload.force_reload_paths << Rails.root.join("app/javascript")
end

Disable livereload

To temporarily disable livereload use:

bin/rails livereload:disable

To re-enable:

bin/rails livereload:enable

No server restart is required. Disabling is managed by tmp/livereload-disabled.txt file.

Development

To get started:

  1. Run npm install
  2. Run npm run watch

License

Hotwire::Livereload is released under the MIT License.