From b10fa0e9cadf6bd672a831ae0d5637a8c4fd74aa Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Tue, 17 May 2022 18:40:43 +0200 Subject: [PATCH] wip --- README.md | 30 ++++++++++++++++++++++++++---- bb.edn | 16 ++++++++++++---- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index ec52c4e..30c33d9 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,20 @@ for a minimal full stack web application. See [releases](https://github.com/babashka/scittle/releases) for links to [JSDelivr](https://www.jsdelivr.com) to get versioned artifacts. -## REPL +## Developing with scittle + +### Serving assets + +To serve assets you can use the +[babashka.http-server](https://github.com/babashka/http-server) dependency: + +``` clojure +(require '[babashka.http-server :as http]) +(http/serve {:port 1341 :dir "resoures/public"} +@(promise) ;; wait until process is killed +``` + +### REPL To connect to a Scittle REPL from your editor, scittle provides an nREPL implementation. To run the nREPL server you need to follow these steps: @@ -22,8 +35,8 @@ In babashka or Clojure JVM, use the [sci.nrepl](https://github.com/babashka/sci.nrepl) dependency and run: ``` -(require 'sci.nrepl.browser-server :as bp) -(bp/start! {:nrepl-port 1339 :websocket-port 1340}) +(require 'sci.nrepl.browser-server :as nrepl) +(nrepl/start! {:nrepl-port 1339 :websocket-port 1340}) ``` This will run an nREPL server on port 1339 and a websocket server on port 1340. @@ -35,9 +48,18 @@ the normal routine: ``` - + ``` +Also include the CLJS file that you want to evaluate with nREPL: + +``` + +``` + +Then visit `cljs/script.cljs` in your editor and connect to the nREPL server, +and start evaluating! + ## Tasks Run `bb tasks` to see all available tasks: diff --git a/bb.edn b/bb.edn index 5d1e088..9a89e71 100644 --- a/bb.edn +++ b/bb.edn @@ -1,6 +1,8 @@ {:deps {io.github.babashka/sci.nrepl - {:local/root "../sci.nrepl"} - #_{:git/sha "318e39fc356652d749180f3a3efba5eb4b99d304"}} + #_{:local/root "../sci.nrepl"} + {:git/sha "c14b5b4ef4390ff206cdb71f763f327799f5e853"} + io.github.babashka/http-server + {:git/sha "b38c1f16ad2c618adae2c3b102a5520c261a7dd3"}} :tasks {:requires ([babashka.fs :as fs] @@ -15,14 +17,20 @@ shadow:watch {:doc "Development build. Starts webserver and watches for changes." :task (clojure "-M:dev -m shadow.cljs.devtools.cli watch main")} + http-server {:doc "Starts http server for serving static files" + :requires ([babashka.http-server :as http]) + :task (do (http/serve {:port 1341 :dir "resources/public"}) + (println "Serving static assets at http://localhost:1341"))} + browser-nrepl {:doc "Start browser nREPL" :requires ([sci.nrepl.browser-server :as bp]) :task (bp/start! {})} - -dev {:depends [shadow:watch browser-nrepl]} + -dev {:depends [shadow:watch browser-nrepl http-server]} dev {:doc "Development build. Starts webserver and watches for changes." - :task (run '-dev {:parallel true})} + :task (do (run '-dev {:parallel true}) + (deref (promise)))} prod {:doc "Builds production artifacts." :task (clojure {:extra-env {"SCI_ELIDE_VARS" "true"}}