Skip to content

Commit 24b8be7

Browse files
committed
.
1 parent 0fd5b8f commit 24b8be7

File tree

2 files changed

+72
-34
lines changed

2 files changed

+72
-34
lines changed

project/src/live.server.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ object LiveServer
7777
// }
7878

7979
val logLevelOpt: Opts[String] = Opts
80-
.option[String]("log-level", help = "The log level (e.g., info, debug, error)")
80+
.option[String]("log-level", help = "The log level. info, debug, error, trace)")
8181
.withDefault("info")
8282
.validate("Invalid log level") {
8383
case "info" => true
@@ -116,7 +116,7 @@ object LiveServer
116116
.validate("Must be a directory")(sOpt => sOpt.fold(true)(s => os.isDir(os.Path(s))))
117117

118118
val portOpt = Opts
119-
.option[Int]("port", "The port yo want to run the server on - e.g. 3000")
119+
.option[Int]("port", "The port you want to run the server on - e.g. 3000")
120120
.withDefault(3000)
121121
.validate("Port must be between 1 and 65535")(i => i > 0 && i < 65535)
122122
.map(i => Port.fromInt(i).get)

readme.md

Lines changed: 70 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,3 @@
1-
# An experiment in a dev server for scala JS
2-
3-
Try and break the dependance on node / npm completely whilst retaining a sane developer experience for browser based scala-js development.
4-
5-
[Blogpost](https://quafadas.github.io/Whimsy/2024/05/22/Viteless.html)
6-
7-
## Goals
8-
9-
Replicate the "experience" of using vite with scala JS.
10-
11-
- Live reload / link on change
12-
- Hot application of style (no page reload)
13-
- Proxy server
14-
- page open on start
15-
16-
## Contraints
17-
18-
- Scala cli to build frontend
19-
- ESModule output (only)
20-
- Third party ESModules via import map rather than npm
21-
- Styles through LESS
22-
23-
## Assumptions
24-
25-
`cs`, `scala-cli` and `mill` are readily available on the path.
26-
The entry point for styles is `index.less`, and that file exists in the styles directory. It can link to other style files.
27-
App must be mounted to a div, with id `app`.
28-
29-
## Contributing
30-
31-
CI builds a container image which is ready to roll.
32-
331
## TL:DR
342

353
```sh
@@ -94,3 +62,73 @@ The intention, is for the simple case to be zero configuration. The below invoca
9462
- Your application, will mount in a div with id `app`.
9563

9664
The file above is a one file example of such a project, satisfying these constraints.
65+
66+
The dream, is for the CLI to be flexible enough to accomodate more complex scenarios as well.
67+
68+
```sh
69+
simon@Simons-Mac-mini cwazy % cs launch io.github.quafadas:live-server-scala-cli-js_3:0.0.10 -- --help
70+
Usage: LiveServer [--project-dir <string>] [--out-dir <string>] [--styles-dir <string>] [--port <integer>] [--proxy-target-port <integer>] [--proxy-prefix-path <string>] [--log-level <string>] --build-tool <string> [--browse-on-open-at <string>] [--extra-build-args <string>]... [--mill-module-name <string>] [--path-to-index-html-template <string>]
71+
72+
Scala JS live server
73+
74+
Options and flags:
75+
--help
76+
Display this help text.
77+
--version, -v
78+
Print the version number and exit.
79+
--project-dir <string>
80+
The fully qualified location of your project - e.g. c:/temp/helloScalaJS
81+
--out-dir <string>
82+
Where the compiled JS will be compiled to - e.g. c:/temp/helloScalaJS/.out
83+
--styles-dir <string>
84+
A fully qualified path to your styles directory with LESS files in - e.g. c:/temp/helloScalaJS/styles
85+
--port <integer>
86+
The port you want to run the server on - e.g. 3000
87+
--proxy-target-port <integer>
88+
The port you want to forward api requests to - e.g. 8080
89+
--proxy-prefix-path <string>
90+
Match routes starting with this prefix - e.g. /api
91+
--log-level <string>
92+
The log level (e.g. info, debug, error, trace)
93+
--build-tool <string>
94+
scala-cli or mill
95+
--browse-on-open-at <string>
96+
A suffix to localhost where we'll open a browser window on server start - e.g. /ui/greatPage OR just `/` for root
97+
--extra-build-args <string>
98+
Extra arguments to pass to the build tool
99+
--mill-module-name <string>
100+
Extra arguments to pass to the build tool
101+
```
102+
103+
104+
# An experiment in a dev server for scala JS
105+
106+
Try and break the dependance on node / npm completely whilst retaining a sane developer experience for browser based scala-js development.
107+
108+
[Blogpost](https://quafadas.github.io/Whimsy/2024/05/22/Viteless.html)
109+
110+
## Goals
111+
112+
Replicate the "experience" of using vite with scala JS.
113+
114+
- Live reload / link on change
115+
- Hot application of style (no page reload)
116+
- Proxy server
117+
- page open on start
118+
119+
## Contraints
120+
121+
- Scala cli to build frontend
122+
- ESModule output (only)
123+
- Third party ESModules via import map rather than npm
124+
- Styles through LESS
125+
126+
## Assumptions
127+
128+
`cs`, `scala-cli` and `mill` are readily available on the path.
129+
The entry point for styles is `index.less`, and that file exists in the styles directory. It can link to other style files.
130+
App must be mounted to a div, with id `app`.
131+
132+
## Contributing
133+
134+
CI builds a container image which is ready to roll.

0 commit comments

Comments
 (0)