Shard Detail

live_reload v0.1.0

A LiveReload server implementation in Crystal

Install & Use

Add the following code to your project's shard.yml under:

dependencies to use in production
- OR -
development_dependencies to use in development


live_reload:
  github: bcardiff/live_reload.cr

Readme

LiveReload.cr

This is a LiveReload server implementation in Crystal.

It creates an HTTP server at http://0.0.0.0:35729 that serves the /livereload.js script and handles official-7 protocol via websocket.

Currently, it does not watch the filesystem for changes. You can use bcardiff/crystal-fswatch or petoem/inotify.cr and trigger a LiveReload::Server#send_reload.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      live_reload:
        github: bcardiff/live_reload.cr
    
  2. Run shards install

Usage

require "live_reload"
require "fswatch"

dir = Dir.current
live_reload = LiveReload::Server.new
FSWatch.watch dir do |event|
  live_reload.send_reload(path: event.path, liveCSS: event.path.ends_with?(".css"))
end

puts "Watching changes from #{dir}"
puts "LiveReload on http://#{live_reload.address}"

live_reload.listen

Contributing

  1. Fork it (https://github.com/bcardiff/live_reload.cr/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors