{"id":29097402,"url":"https://github.com/lambdaisland/garden-watcher","last_synced_at":"2025-12-12T01:07:58.721Z","repository":{"id":47102201,"uuid":"77611001","full_name":"lambdaisland/garden-watcher","owner":"lambdaisland","description":"A component that watches-and-recompiles your Garden stylesheets.","archived":false,"fork":false,"pushed_at":"2021-09-13T14:28:26.000Z","size":53,"stargazers_count":25,"open_issues_count":1,"forks_count":11,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-17T07:01:21.471Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lambdaisland.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-29T12:34:47.000Z","updated_at":"2025-05-01T13:53:16.000Z","dependencies_parsed_at":"2022-08-25T11:02:08.720Z","dependency_job_id":null,"html_url":"https://github.com/lambdaisland/garden-watcher","commit_stats":null,"previous_names":["plexus/garden-component","plexus/garden-watcher"],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/lambdaisland/garden-watcher","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdaisland%2Fgarden-watcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdaisland%2Fgarden-watcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdaisland%2Fgarden-watcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdaisland%2Fgarden-watcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lambdaisland","download_url":"https://codeload.github.com/lambdaisland/garden-watcher/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lambdaisland%2Fgarden-watcher/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281397338,"owners_count":26493908,"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-28T02:00:06.022Z","response_time":60,"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":[],"created_at":"2025-06-28T13:42:15.959Z","updated_at":"2025-10-28T06:37:48.558Z","avatar_url":"https://github.com/lambdaisland.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Garden reloader component\n\nWatch your [Garden](https://github.com/noprompt/garden) stylesheets for changes,\nand compiles them to CSS.\n\n## Quickstart\n\nAdd `lambdaisland/garden-watcher` as a dependency in `deps.edn` (Clojure CLI),\n`project.clj` (Leiningen) or `build.boot` (Boot).\n\n```\n;; deps.edn\n{lambdaisland/garden-watcher {:mvn/version \"1.0.45\"}}\n\n;; project.clj/build.boot\n[lambdaisland/garden-watcher \"1.0.45\"]\n```\n\nCreate vars containing Garden-style declarations, and add a `^:garden` metadata\nto the var.\n\n``` clojure\n(ns sesame.styles)\n\n(def ^:garden main\n  (list\n   [:h1 {:color \"blue\"}]\n   [:h2 {:color \"green\"}]\n   [:h3 {:color \"red\"}]))\n```\n\nNow you start garden-watcher, passing it your namespace name, and it will\nrecompile the stylesheet and create a `main.css` file whenever the namespace\nchanges. You can start garden-watcher in several ways. For more metadata options\n(e.g. to control the output file) and a convenience macro (`defstyles`), see\nbelow.\n\n### Use with `garden-watcher.main`\n\nThere's a main namespace that's convenient if you want to simply run the watcher\nas its own process. You pass one or more namespace names as arguments.\n\n```\n;; leiningen\nlein run -m garden-watcher.main name.of.your.namespace\n\n;; clojure CLI\nclj -m garden-watcher.main name.of.your.namespace\n```\n\n### Use as a library\n\nThere are start/stop functions so you can hook this up however you like. Useful\nfor use with Integrant, Mount, etc.\n\n``` clojure\n(require '[garden-watcher.core :as gw])\n\n(def watcher (gw/start-garden-watcher! '[name.of.namespace name.of.other.namespace]))\n(gw/stop-garden-watcher! watcher)\n```\n\n### Use as a Component\n\nIf you're using `com.stuartsierra.component` then you can use the built-in\ncomponent directly.\n\nUse `garden-watcher.core/new-garden-watcher` to create the component, passing it\na vector of namespace names. Once started this will watch and compile each var\nwith a `:garden` metadata key in the given namespaces to a CSS file.\nAlso, [hawk](https://github.com/wkf/hawk) options map can be passed as a second argument.\n\n``` clojure\n(ns user\n  (:require [com.stuartsierra.component :as component]\n            [figwheel-sidecar.config :as fw-conf]\n            [figwheel-sidecar.system :as fw-sys]\n            [garden-watcher.core :refer [new-garden-watcher]])) ;; \u003c------\n\n(defn dev-system []\n  (component/system-map\n   :figwheel-system (fw-sys/figwheel-system (fw-conf/fetch-config))\n   :css-watcher (fw-sys/css-watcher {:watch-paths [\"resources/public/css\"]})\n   :garden-watcher (new-garden-watcher '[sesame.styles]))) ;; \u003c------\n```\n\nThe above will generate `resources/public/css/main.css`, and recreate it\nwhenever `styles.clj` is saved. By combining it with Figwheel's CSS reloader you\nget instant reloading in the browser.\n\n## Use of metadata\n\nGarden provides a macro, `garden.def/defstylesheet`, that allows you to pass\ncompiler options to `garde.core/css`. By adding `:output-to` this allows writing\nstylesheets that \"automatically\" create the corresponding CSS files. When using\ngarden-watcher you should *not* use `defstylesheet`.\n\nWith `defstylesheet` the compile-to-CSS happens as a side effect of loading the\nnamespace, which makes it impossible to load the namespace without generating\nthe CSS file, or generating the CSS without reloading the namespace. Therefore\n`garden-watcher` chose a different approach.\n\nInstead create regular vars, adn tag them with a `:garden` metadata key. You can\nuse a map to add compiler options, including `:output-to`.\n\n``` clojure\n(def\n  ^{:garden {:output-to \"resources/public/styles.css\"\n             :vendors [\"webkit\"]}}\n  my-stylesheet\n  (list\n   [:h1 {:color \"blue\"}]))\n```\n\nIf you don't specify an output file, it defaults to `resources/public/css/{{var-name}}.css`\n\n``` clojure\n;; This creates resources/public/css/anja.css\n(def ^:garden anja\n  (list\n   [:h1 {:color \"blue\"}]))\n```\n\nNote that Garden provides `garden.def/defstyles` macro that allows you to get\nrid of the `(list ,,,)` (that's all that macro does), so this code is equivalent:\n\n``` clojure\n(require '[garden.def :refer [defstyles]])\n\n(defstyles ^:garden anja\n  [:h1 {:color \"blue\"}])\n```\n\nOr you can use `garden-watcher.def/defstyles`, which does the exact same thing,\nbut automatically adds the `:garden` metadata, so this code is equivalent again:\n\n``` clojure\n(require '[garden-watcher.def :refer [defstyles]]) ;; \u003c-- different namespace\n\n(defstyles anja\n  [:h1 {:color \"blue\"}])\n```\n\n## One-off Compiling to CSS\n\nTo generate CSS files from these vars, use\n`garden-watcher.core/compile-garden-namespaces`:\n\n``` clojure\n(compile-garden-namespaces '[sesame.styles])\n```\n\ngarden-watcher also includes a \"main\" entry point to make it easy to invoke\nthis as a build step.\n\n```\nlein run -m garden-watcher.main sesame.styles\n```\n\nE.g. say you're building an uberjar containing compiled ClojureScript and CSS.\n\n``` clojure\n(defproject sesame \"0.1.0\"\n  ,,,\n  :uberjar-name \"sesame.jar\"\n\n  :profiles {,,,\n\n             :uberjar\n             {:prep-tasks [\"compile\"\n                           [\"cljsbuild\" \"once\" \"min\"]\n                           [\"run\" \"-m\" \"garden-watcher.main\" \"sesame.styles\"]]\n              :omit-source true\n              :aot :all}})\n```\n\n## CLJC support\n\nIn order to share code with Clojurescript, `cljc` files are fully supported.\nHowever, note that priority is given to regular `clj` files when both kind\nexist for a given namespace.\n\n## License\n\nCopyright © 2016-2019 Arne Brasseur\n\nDistributed under the Mozilla Public License 2.0 (https://www.mozilla.org/en-US/MPL/2.0/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flambdaisland%2Fgarden-watcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flambdaisland%2Fgarden-watcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flambdaisland%2Fgarden-watcher/lists"}