|
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 | | - |
33 | 1 | ## TL:DR |
34 | 2 |
|
35 | 3 | ```sh |
@@ -94,3 +62,73 @@ The intention, is for the simple case to be zero configuration. The below invoca |
94 | 62 | - Your application, will mount in a div with id `app`. |
95 | 63 |
|
96 | 64 | 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