http-server-rs 0.0.44 → 0.0.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -58,7 +58,7 @@ http-server-rs serve --cors --spa -Z ./public
|
|
|
58
58
|
# Responds with headers required for SharedArrayBuffer
|
|
59
59
|
http-server-rs serve --shared-array-buffer ./public
|
|
60
60
|
|
|
61
|
-
# Automatically transpiles TypeScript to JavaScript on request
|
|
61
|
+
# Automatically transpiles TypeScript to JavaScript and Sass to CSS on request
|
|
62
62
|
http-server-rs serve --transpile ./public
|
|
63
63
|
|
|
64
64
|
# Proxy /api to an external backend (quotes are required)
|
|
@@ -132,9 +132,17 @@ Options:
|
|
|
132
132
|
Print help
|
|
133
133
|
```
|
|
134
134
|
|
|
135
|
-
## On-The-Fly
|
|
135
|
+
## On-The-Fly Transpilation
|
|
136
136
|
|
|
137
|
-
Write your application as if your browser natively supports TypeScript.
|
|
137
|
+
Write your application as if your browser natively supports TypeScript and Sass.
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
http-server-rs serve --transpile .
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
https://github.com/user-attachments/assets/3d1bc313-e898-42bb-8c8f-a8023c41ec35
|
|
144
|
+
|
|
145
|
+
### Typescript
|
|
138
146
|
|
|
139
147
|
The server will on-the-fly transpile TypeScript to JavaScript on request. This allows serving TypeScript sources
|
|
140
148
|
directly to the browser without a build step.
|
|
@@ -146,8 +154,6 @@ http-server-rs serve --transpile --port 8080 ./testing/transpile/react
|
|
|
146
154
|
curl http://localhost:8080/app.tsx
|
|
147
155
|
```
|
|
148
156
|
|
|
149
|
-
https://github.com/user-attachments/assets/3d1bc313-e898-42bb-8c8f-a8023c41ec35
|
|
150
|
-
|
|
151
157
|
Notes;
|
|
152
158
|
- Use builtin `import` syntax
|
|
153
159
|
- Libraries are fetched from a CDN (like [esm.sh](https://esm.sh/#tsx)) or vendored locally (no `npm`)
|
|
@@ -156,6 +162,24 @@ Notes;
|
|
|
156
162
|
- Unfortunately, [TypeScript does not support remote declaration files](https://github.com/microsoft/TypeScript/issues/28985). If you want to use tsc you need to install packages using `npm` and configure a `tsconfig.json`.
|
|
157
163
|
- For performance sensitive applications, you'll still probably want to use a bundler for production - but who know, this might be good enough for most use cases
|
|
158
164
|
|
|
165
|
+
### Sass
|
|
166
|
+
|
|
167
|
+
Requests for `.scss` and `.sass` files are compiled to CSS and served with the `text/css` content type.
|
|
168
|
+
|
|
169
|
+
Imports (`@use` / `@import`) are resolved on the fly, including partials, so a stylesheet can be linked directly from the page.
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
http-server-rs serve --transpile --port 8080 ./public
|
|
173
|
+
|
|
174
|
+
# Link the source file - the browser receives CSS
|
|
175
|
+
# <link rel="stylesheet" href="/style.scss">
|
|
176
|
+
curl http://localhost:8080/style.scss
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Notes;
|
|
180
|
+
- A file is served at its own path, so the page links `style.scss` rather than a `.css` twin
|
|
181
|
+
- Imports are restricted to the served directory
|
|
182
|
+
|
|
159
183
|
## Watch Mode
|
|
160
184
|
|
|
161
185
|
`http-server` under `--watch` mode can watch the served directory for changes and emit an event to the client notifying of a change. By default the server will intercept html files and inject a JavaScript script which subscribes to change events and triggers a page reload.
|
|
Binary file
|
|
Binary file
|
package/http-server-rs-linux-x64
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|