@t8/serve 0.1.15 → 0.1.16

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.
Files changed (2) hide show
  1. package/README.md +93 -1
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,12 @@
1
+ # @t8/serve
2
+
3
+ Simple static file server + bundler, primarily for tests, manual or automated
4
+
5
+ ## CLI
6
+
1
7
  ```sh
2
8
  npx @t8/serve [url|port] [*] [app_dir] [...assets_dirs] [-b [bundle_input_path] [bundle_output_path]]
3
- # * = SPA mode: serve all paths as "/"
9
+ # * = SPA mode: serve all unmatched paths as "/"
4
10
 
5
11
  npx @t8/serve 3000 app
6
12
  npx @t8/serve 3000 app -b
@@ -11,3 +17,89 @@ npx @t8/serve 127.0.0.1:3000 app public dist
11
17
  npx @t8/serve 3000 app public dist -b
12
18
  npx @t8/serve 3000 app public dist -b src/index.ts
13
19
  ```
20
+
21
+ <details>
22
+ <summary>Example</summary>
23
+
24
+ ```
25
+ // package.json
26
+ "scripts": {
27
+ "play": "npx @t8/serve 3000 * playground -b"
28
+ }
29
+ ```
30
+
31
+ ```
32
+ /playground
33
+ - index.css
34
+ - index.html
35
+ + <script src="/dist/index.js"></script>
36
+ - index.ts
37
+ ```
38
+
39
+ ```sh
40
+ npm run play
41
+ ```
42
+
43
+ ```
44
+ // playwright.config.ts
45
+ ...
46
+ use: {
47
+ baseURL: "http://localhost:3000",
48
+ },
49
+ webServer: {
50
+ command: "npm run play",
51
+ url: "http://localhost:3000",
52
+ },
53
+ ```
54
+
55
+ </details>
56
+
57
+ ## Code
58
+
59
+ ```ts
60
+ import { serve } from "@t8/serve";
61
+
62
+ // Start
63
+ let server = await serve({
64
+ port: 3000,
65
+ path: "app",
66
+ spa: true,
67
+ bundle: true,
68
+ });
69
+
70
+ // Stop
71
+ server.close();
72
+ ```
73
+
74
+ <details>
75
+ <summary>Example</summary>
76
+
77
+ ```
78
+ /playground
79
+ - index.css
80
+ - index.html
81
+ + <script src="/dist/index.js"></script>
82
+ - index.ts
83
+ ```
84
+
85
+ ```ts
86
+ // x.test.ts
87
+ import { test } from "@playwright/test";
88
+ import { serve, type Server } from "@t8/serve";
89
+
90
+ let server: Server;
91
+
92
+ test.beforeAll(async () => {
93
+ server = await serve({
94
+ path: "playground",
95
+ spa: true,
96
+ bundle: true,
97
+ });
98
+ });
99
+
100
+ test.afterAll(() => {
101
+ server.close();
102
+ });
103
+ ```
104
+
105
+ </details>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t8/serve",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "node",