wip
This commit is contained in:
parent
b152ddf7ea
commit
b10fa0e9ca
2 changed files with 38 additions and 8 deletions
30
README.md
30
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:
|
|||
|
||||
```
|
||||
<script>var SCITTLE_NREPL_WEBSOCKET_PORT = 1340;</script>
|
||||
<script src="js/scittle.nrepl.js" type="application/javascript"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/scittle@0.2.0/dist/scittle.nrepl.js" type="application/javascript"></script>
|
||||
```
|
||||
|
||||
Also include the CLJS file that you want to evaluate with nREPL:
|
||||
|
||||
```
|
||||
<script src="cljs/script.cljs" type="application/x-scittle"></script>
|
||||
```
|
||||
|
||||
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:
|
||||
|
|
|
|||
16
bb.edn
16
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"}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue