|
1 | 1 | # Development Server Enhancement
|
2 | 2 |
|
3 |
| -This directory contains enhanced development server scripts that improve the BigCommerce Checkout JS development workflow. |
| 3 | +This directory contains enhanced development server scripts that improve the BigCommerce Checkout JS development workflow using [listhen](https://github.com/unjs/listhen). |
4 | 4 |
|
5 | 5 | ## Scripts
|
6 | 6 |
|
7 | 7 | ### dev-server.js
|
8 |
| -Main development server script that combines webpack development build with HTTP server and optional Cloudflare Tunnels integration. |
| 8 | +Main development server script that combines webpack development build with HTTP server and optional tunneling via listhen. |
9 | 9 |
|
10 | 10 | **Features:**
|
11 | 11 | - Unified command to start both webpack dev build and HTTP server
|
12 |
| -- Optional HTTPS tunneling via Cloudflare Tunnels |
13 |
| -- Automatic process management and cleanup |
| 12 | +- Optional HTTPS tunneling via listhen (powered by untun) |
| 13 | +- Automatic port selection and process management |
14 | 14 | - Configurable via CLI arguments or environment variables
|
15 | 15 | - Verbose logging mode for debugging
|
16 |
| - |
17 |
| -### install-cloudflared.js |
18 |
| -Automatically downloads and installs the cloudflared binary required for tunnel functionality. |
19 |
| - |
20 |
| -**Features:** |
21 |
| -- Automatic download from GitHub releases |
22 |
| -- Cross-platform support (currently Linux) |
23 |
| -- Proper executable permissions setup |
24 |
| -- Graceful failure handling |
| 16 | +- Built-in static file serving with CORS support |
25 | 17 |
|
26 | 18 | ### test-dev-server.js
|
27 | 19 | Test script to verify the development server functionality.
|
@@ -51,16 +43,26 @@ node scripts/dev-server.js --port 9000 --tunnel --verbose
|
51 | 43 | ## Environment Variables
|
52 | 44 |
|
53 | 45 | - `DEV_SERVER_TUNNEL`: Enable tunnel mode ('true'/'false')
|
54 |
| -- `DEV_SERVER_PORT`: HTTP server port (default: 8080) |
| 46 | +- `DEV_SERVER_PORT`: HTTP server port (default: 8080, auto-selected with listhen) |
55 | 47 | - `DEV_SERVER_VERBOSE`: Enable verbose logging ('true'/'false')
|
56 |
| -- `CLOUDFLARED_PATH`: Custom path to cloudflared binary |
| 48 | +- `DEV_SERVER_BUILD_DIR`: Build directory to serve (default: build) |
57 | 49 |
|
58 | 50 | ## Architecture
|
59 | 51 |
|
60 |
| -The dev-server.js script manages multiple processes: |
| 52 | +The dev-server.js script manages: |
61 | 53 |
|
62 | 54 | 1. **Webpack Process**: Runs `npm run dev` for watch mode compilation
|
63 |
| -2. **HTTP Server Process**: Runs `http-server` on the build directory |
64 |
| -3. **Cloudflared Process** (optional): Creates HTTPS tunnel |
| 55 | +2. **Listhen Server**: Elegant HTTP server with optional tunneling capabilities |
| 56 | + - Static file serving for the build directory |
| 57 | + - Automatic CORS headers |
| 58 | + - SPA routing support (fallback to index.html) |
| 59 | + - Optional HTTPS tunnel via untun/cloudflared |
| 60 | + |
| 61 | +All processes are managed with proper signal handling and cleanup on exit. |
| 62 | + |
| 63 | +## Benefits of Listhen Integration |
65 | 64 |
|
66 |
| -All processes are managed with proper signal handling and cleanup on exit. |
| 65 | +- **Automatic port selection**: No more port conflicts during development |
| 66 | +- **Built-in tunneling**: Simplified tunnel setup without manual cloudflared installation |
| 67 | +- **Better error handling**: Graceful fallbacks when tunneling is unavailable |
| 68 | +- **Modern architecture**: Based on unjs ecosystem with h3 and nitro foundation |
0 commit comments