{"id":18099999,"url":"https://github.com/kevinlang/plug_live_reload","last_synced_at":"2025-10-24T20:44:43.385Z","repository":{"id":57534725,"uuid":"395455368","full_name":"kevinlang/plug_live_reload","owner":"kevinlang","description":"Adds live-reload functionality to Plug for development.","archived":false,"fork":false,"pushed_at":"2023-12-14T00:49:09.000Z","size":38,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-10T17:15:55.896Z","etag":null,"topics":["elixir","plug"],"latest_commit_sha":null,"homepage":"https://hexdocs.pm/plug_live_reload/","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kevinlang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-12T22:10:08.000Z","updated_at":"2025-04-10T06:11:49.000Z","dependencies_parsed_at":"2023-12-14T01:38:11.985Z","dependency_job_id":"2433fb2d-ad9e-4290-8464-bff35c8a1885","html_url":"https://github.com/kevinlang/plug_live_reload","commit_stats":{"total_commits":13,"total_committers":1,"mean_commits":13.0,"dds":0.0,"last_synced_commit":"7b5b33ee3e662d97c75f8e9bbe95525940fc3944"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/kevinlang/plug_live_reload","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinlang%2Fplug_live_reload","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinlang%2Fplug_live_reload/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinlang%2Fplug_live_reload/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinlang%2Fplug_live_reload/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kevinlang","download_url":"https://codeload.github.com/kevinlang/plug_live_reload/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinlang%2Fplug_live_reload/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280865019,"owners_count":26404439,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-24T02:00:06.418Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elixir","plug"],"created_at":"2024-10-31T21:12:38.157Z","updated_at":"2025-10-24T20:44:43.356Z","avatar_url":"https://github.com/kevinlang.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PlugLiveReload\n\nAdds live-reload functionality to [Plug](https://github.com/elixir-plug/plug) for development.\n\n## Installation\n\nYou can use `plug_live_reload` in your projects by adding it to your `mix.exs` dependencies:\n\n```\ndefp deps do\n [\n   {:plug_live_reload, \"~\u003e 0.2.0\", only: :dev}\n ]\nend\n```\n\nOnce that is done, you will want to add the plug to your `Plug.Router`.\n\n```\ndefmodule MyApp.Router do\n  use Plug.Router\n\n  if Mix.env() == :dev do\n    plug PlugLiveReload\n  end\n  \n  plug :match\n  plug :dispatch\n\n  get \"/\" do\n    conn\n    |\u003e put_resp_content_type(\"text/html\")\n    |\u003e send_resp(200, \"\u003chtml\u003e\u003cbody\u003e\u003ch1\u003ePlug\u003c/h1\u003e\u003c/body\u003e\u003c/html\u003e\")\n  end\nend\n```\n\nYou will additionally need to make sure the `PlugLiveReload.Socket` handler is added\nto your `Plug.Cowboy` child spec in your application.\n\n```\ndef start(_type, _args) do\n  children = [\n    {Plug.Cowboy, scheme: :http, plug: MyApp.Router, options: [\n      port: 4000,\n      dispatch: dispatch()\n    ]}\n  ]\n\n  opts = [strategy: :one_for_one, name: MyApp.Supervisor]\n  Supervisor.start_link(children, opts)\nend\n\nif Mix.env() == :dev do\n  def dispatch(),\n    do: [\n      {:_,\n       [\n        {\"/plug_live_reload/socket\", PlugLiveReload.Socket, []},\n        {:_, Plug.Cowboy.Handler, {MyApp.Router, []}}\n       ]}\n    ]\nelse\n  def dispatch(), do: nil\nend\n```\n\nLastly, you will need to configure which file paths to watch.\n\n```\n# config/dev.exs\n\nconfig :plug_live_reload,\n  patterns: [\n    ~r\"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$\",\n  ]\n```\n\nYou can find additional documentation for configuring the `PlugLiveReload` plug and the `PlugLiveReload.Socket` \nin their respective documentation pages.\n\n## Backends\n\nThis project uses [`FileSystem`](https://github.com/falood/file_system) as a dependency to watch your filesystem whenever there is a change and it supports the following operating systems:\n\n* Linux via [inotify](https://github.com/rvoicilas/inotify-tools/wiki) (installation required)\n* Windows via [inotify-win](https://github.com/thekid/inotify-win) (no installation required)\n* Mac OS X via fsevents (no installation required)\n* FreeBSD/OpenBSD/~BSD via [inotify](https://github.com/rvoicilas/inotify-tools/wiki) (installation required)\n\nThere is also a `:fs_poll` backend that polls the filesystem and is available on all Operating Systems in case you don't want to install any dependency. You can configure the `:backend` in your `config/config.exs`:\n\n```elixir\nconfig :plug_live_reload,\n  backend: :fs_poll\n```\n\nBy default the entire application directory is watched by the backend. However, with some environments and backends, this may be inefficient, resulting in slow response times to file modifications. To account for this, it's also possible to explicitly declare a list of directories for the backend to watch, and additional options for the backend:\n\n```elixir\nconfig :plug_live_reload,\n  dirs: [\n    \"priv/static\",\n    \"priv/gettext\",\n    \"lib/example_web/live\",\n    \"lib/example_web/views\",\n    \"lib/example_web/templates\",\n  ],\n  backend: :fs_poll,\n  backend_opts: [\n    interval: 500\n  ]\n```\n\n## Skipping remote CSS reload\n\nAll stylesheets are reloaded without a page refresh anytime a style is detected as having changed. In certain cases such as serving stylesheets from a remote host, you may wish to prevent unnecessary reload of these stylesheets during development. For this, you can include a `data-no-reload` attribute on the link tag, ie:\n\n    \u003clink rel=\"stylesheet\" href=\"http://example.com/style.css\" data-no-reload\u003e\n\n## Credits\n\nMost of this code was adapted from [`phoenix_live_reload`](https://github.com/phoenix/phoenix_live_reload). \nThe main difference is that this package is plug-specific and takes no Phoenix dependencies.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevinlang%2Fplug_live_reload","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkevinlang%2Fplug_live_reload","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevinlang%2Fplug_live_reload/lists"}