From d1ee87f52851e7e9000a021a12aa6912c5f158d8 Mon Sep 17 00:00:00 2001 From: Simon Parten Date: Thu, 18 Jul 2024 16:53:23 +0200 Subject: [PATCH] doc update --- build.sc | 4 +- readme.md | 151 +++----------------------------------- site/docs/_docs/config.md | 2 +- site/docs/_docs/index.md | 2 +- 4 files changed, 14 insertions(+), 145 deletions(-) diff --git a/build.sc b/build.sc index f2e5d16..d4c29e3 100644 --- a/build.sc +++ b/build.sc @@ -111,9 +111,7 @@ object site extends SiteModule { def scalaVersion = sjsls.scalaVersion - override def moduleDeps = Seq(sjsls) - - override def scalaDocOptions: Target[Seq[String]] = super.scalaDocOptions() ++ List("-runWith", "sjsls") + override def moduleDeps = Seq(sjsls) } // SN deps which aren't yet there. diff --git a/readme.md b/readme.md index 1193123..1bf9b06 100644 --- a/readme.md +++ b/readme.md @@ -1,136 +1,29 @@ -## TL:DR +See [docs](https://quafadas.github.io/live-server-scala-cli-js/docs/index.html) -```sh -touch helloScalaJS.scala -``` - -```scala - -//> using scala 3.4.2 -//> using platform js - -//> using dep org.scala-js::scalajs-dom::2.8.0 -//> using dep com.raquo::laminar::17.0.0 +# Scala JS live server TL;DR -//> using jsModuleKind es -//> using jsModuleSplitStyleStr smallmodulesfor -//> using jsSmallModuleForPackage webapp +> Show me scala JS - I have 20 seconds. -package webapp - -import org.scalajs.dom -import org.scalajs.dom.document -import com.raquo.laminar.api.L.{*, given} - -@main -def main: Unit = - renderOnDomContentLoaded( - dom.document.getElementById("app"), - interactiveApp - ) - -def interactiveApp = - val hiVar = Var("Wor") - div( - h1( - s"This was more.scala", - child.text <-- hiVar.signal - ), - p("This asdf df"), - // https://demo.laminar.dev/app/form/controlled-inputs - input( - typ := "text", - controlled( - value <-- hiVar.signal, - onInput.mapToValue --> hiVar.writer - ) - ) - ) -``` +Paste this into your terminal and hit enter. ```sh -cs launch io.github.quafadas:live-server-scala-cli-js_3:0.1.1 -``` - -The intention, is for the simple case to be zero configuration. The below invocation makes the following assumptions; - -- cs (coursier) is on the path -- You are using scala-cli and it is on the path -- You are happy to serve your application on port 3000 -- You wish a browser window to open at the root of the application -- You are invoking it from the root of a directory containing a valid scala JS project that is configured to use ES modules. -- Your application, will mount in a div with id `app`. - -The file above is a one file example of such a project, satisfying these constraints. - -The dream, is for the CLI to be flexible enough to accomodate more complex scenarios as well. - -``` -Usage: LiveServer [--project-dir ] [--out-dir ] [--port ] [--proxy-target-port ] [--proxy-prefix-path ] [--log-level ] [--build-tool ] [--browse-on-open-at ] [--extra-build-args ]... [--mill-module-name ] [--path-to-index-html ] [--styles-dir ] - -Scala JS live server -Options and flags: - --help - Display this help text. - --version, -v - Print the version number and exit. - --project-dir - The fully qualified location of your project - e.g. c:/temp/helloScalaJS - --out-dir - Where the compiled JS will be compiled to - e.g. c:/temp/helloScalaJS/.out. If no file is given, a temporary directory is created. - --port - The port you want to run the server on - e.g. 3000 - --proxy-target-port - The port you want to forward api requests to - e.g. 8080 - --proxy-prefix-path - Match routes starting with this prefix - e.g. /api - --log-level - The log level. info, debug, error, trace - --build-tool - scala-cli or mill - --browse-on-open-at - A suffix to localhost where we'll open a browser window on server start - e.g. /ui/greatPage OR just `/` for root - --extra-build-args - Extra arguments to pass to the build tool - --mill-module-name - Extra arguments to pass to the build tool - --path-to-index-html - a path to a directory which contains index.html. The entire directory will be served as static assets - --styles-dir - A fully qualified path to your styles directory with LESS files in - e.g. c:/temp/helloScalaJS/styles +scala-cli --version && \ +cs version && \ +git clone https://github.com/Quafadas/viteless.git && \ +cd viteless && \ +cs launch io.github.quafadas::sjsls:{{projectVersion}} ``` -To be minimally viable for me personally, -- A Proxy server to the backend -- Style application -- Mill -- Some way, to integrate the outcome into a deployment pipline - -As the project is somehwhat young, the approach these points may remain chaotic... your contribution or opinion on them is welcome :-). - -# An experiment in a dev server for scala JS - -Try and break the dependance on node / npm completely whilst retaining a sane developer experience for browser based scala-js development. - -[Blogpost](https://quafadas.github.io/Whimsy/2024/05/22/Viteless.html) - ## Goals -Replicate the "experience" of using vite with scala JS. +Replicate the "experience" of using vite with scala JS. Without vite. - Live reload / link on change - Hot application of style (no page reload) - Proxy server - page open on start -## Contraints - -- Scala cli to build frontend -- ESModule output (only) -- Third party ESModules via import map rather than npm -- Styles through LESS - ## Assumptions `cs`, `scala-cli` and `mill` are readily available on the path. @@ -139,26 +32,4 @@ App must be mounted to a div, with id `app`. ## Contributing -CI builds a container image which is ready to roll. - -## Providing your own HTML - -You'll need to make sure it includes this script. Otherwise no reload on change. - -```html - - -``` - -# Windows - -Ought to work. However, it appears impossible to get it to work in CI. See the `doze` branch. Therefore, windows testing is ad hoc. \ No newline at end of file +It's so welcome. Start a dicsussion if you'd like so ideas! CI builds a container image which is ready to roll. \ No newline at end of file diff --git a/site/docs/_docs/config.md b/site/docs/_docs/config.md index 95f84be..adf1286 100644 --- a/site/docs/_docs/config.md +++ b/site/docs/_docs/config.md @@ -3,7 +3,7 @@ The server is a CLI. It has a number of flags that can be used to configure it. Here is the current list of flags and what they do. You can see these flags by running ` --help` in your terminal. ``` -cs launch io.github.quafadas:live-server-scala-cli-js_3:{{projectVersion}} -- --help +cs launch io.github.quafadas::sjsls:{{projectVersion}} -- --help ``` diff --git a/site/docs/_docs/index.md b/site/docs/_docs/index.md index e403b74..0d6e519 100644 --- a/site/docs/_docs/index.md +++ b/site/docs/_docs/index.md @@ -10,7 +10,7 @@ scala-cli --version && \ cs version && \ git clone https://github.com/Quafadas/viteless.git && \ cd viteless && \ -cs launch io.github.quafadas:live-server-scala-cli-js_3:{{projectVersion}} +cs launch io.github.quafadas::sjsls:{{projectVersion}} ``` ## It worked... okay... I have 20 more seconds