fix various build inconsistencies

This commit is contained in:
2026-10-12 17:03:46 -06:00
parent 7bf36b0845
commit 6fb4314b3a
17 changed files with 129 additions and 85 deletions
+34 -28
View File
@@ -9,9 +9,9 @@ This guide explains how to build TimeSafari for different platforms using the co
```bash
# 🖥️ Web Development
npm install # setup -- and pkgx.dev `dev` command before this will set environment with npm, etc
npm run build:web:serve -- --test # Start with test endorser server
npm run dev # Start development server with hot reload with local endorser server
npm run build:web:prod # Production build
npm run build:web:serve:test # Test build served from dist/ (test endorser server)
npm run build:web # Production build into dist/
# 📱 Mobile Development
npm run build:ios # iOS build (opens Xcode)
@@ -225,30 +225,35 @@ npm install
```bash
# Local development
npm run dev # Start development server with hot reload (shortcut for `build:web:dev`)
npm run dev # Start development server with hot reload (writes nothing to dist/)
# Web builds
npm run build:web # Development build (starts dev server with hot reload)
# Web builds (each one writes dist/)
npm run build:web # Production build (same as build:web:prod)
npm run build:web:test # Test environment build (optimized for testing)
npm run build:web:prod # Production build (optimized for production)
npm run build:web:serve # Build and serve locally for production testing
# Build, then serve dist/ locally
npm run build:web:serve # Production build, then serve
npm run build:web:serve:test # Test build, then serve
# Docker builds
npm run build:web:docker # Development build with Docker containerization
npm run build:web:docker # Production build with Docker containerization
npm run build:web:docker:test # Test build with Docker containerization
npm run build:web:docker:prod # Production build with Docker containerization
```
### Local Development
Start the development server using `npm run dev` (a shortcut for `npm run build:web:dev`) or `npm run build:web` (both start the development server with hot reload).
Start the development server with hot reload using `npm run dev`. Open it at `http://localhost:8080/`, not at a wildcard address such as `http://[::]:8080/` or `http://0.0.0.0:8080/`: browsers only allow the cryptography the app needs on HTTPS, `localhost`, `127.0.0.1`, or `[::1]`, so any other plain-HTTP address shows a "Cannot Start Here" page.
### Web Build for Server
1. Run the production build using `npm run build:web:prod`
1. Run the production build using `npm run build:web` (or `npm run build:web:test` for the test server)
2. The built files will be in the `dist` directory
3. To test the production build locally, use `npm run build:web:serve` (builds then serves)
`dist/` is shared with the Android, iOS, Electron, and Capacitor builds, which overwrite it with non-web output. Run the web build immediately before deploying, and confirm that the browser console reports `Loading TimeSafari for platform: web`.
**Why Use `serve`?**
- **Production Testing**: Test your optimized production build locally before deployment
- **SPA Routing Validation**: Verify deep linking and navigation work correctly (handles routes like `/discover`, `/account`)
@@ -1603,8 +1608,7 @@ Use the commands above to check and fix code quality issues.
1. **Environment Setup**: Load platform-specific environment variables
2. **Asset Building**: Vite builds optimized web assets
3. **PWA Generation**: Service worker and manifest creation
4. **Output**: Production-ready files in `dist/` directory
3. **Output**: Production-ready files in `dist/` directory
### Electron Build Process
@@ -1880,14 +1884,14 @@ npx prettier --write ./sw_scripts/
The `prebuild` script automatically runs before any build:
```json
"prebuild": "eslint --ext .js,.ts,.vue --ignore-path .gitignore src && node sw_combine.js && node scripts/copy-wasm.js"
"prebuild": "eslint --ext .js,.ts,.vue --ignore-path .gitignore src && node scripts/copy-wasm.js"
```
**What happens automatically:**
npm runs `prebuild` only before a script named `build`. This project defines no `build` script, so none of the `build:*` commands trigger it.
- **ESLint**: Checks and fixes code formatting in `src/`
- **Script Combination**: `sw_combine.js` combines all `sw_scripts/*.js` files
into `sw_scripts-combined.js`
**What it does when run:**
- **ESLint**: Checks code formatting in `src/`
- **WASM Copy**: `copy-wasm.js` copies SQLite WASM files to `public/wasm/`
#### Build Process Architecture
@@ -1897,9 +1901,8 @@ The `prebuild` script automatically runs before any build:
```text
1. Pre-Build: ESLint + Script Combination + WASM Copy
2. Environment Setup: Load .env files, set NODE_ENV
3. Vite Build: Bundle web assets with PWA support
4. Service Worker: Inject combined scripts into PWA
5. Output: Production-ready files in dist/
3. Vite Build: Bundle web assets
4. Output: Production-ready files in dist/
```
**Electron Build Process:**
@@ -2062,31 +2065,34 @@ environment setup, Vite build, and optional Docker containerization.
```bash
# Direct script usage
./scripts/build-web.sh # Development build
./scripts/build-web.sh --dev # Development build (explicit)
./scripts/build-web.sh # Production build into dist/
./scripts/build-web.sh --prod # Production build (explicit)
./scripts/build-web.sh --test # Test environment build
./scripts/build-web.sh --prod # Production environment build
./scripts/build-web.sh --docker # Build with Docker containerization
./scripts/build-web.sh --dev # Start Vite dev server (no dist/)
./scripts/build-web.sh --docker # Production build + Docker image
./scripts/build-web.sh --docker:test # Test environment + Docker
./scripts/build-web.sh --docker:prod # Production environment + Docker
./scripts/build-web.sh --serve # Build and serve locally
./scripts/build-web.sh --serve # Production build, then serve dist/
./scripts/build-web.sh --help # Show help
./scripts/build-web.sh --verbose # Enable verbose logging
# NPM Script Equivalents
npm run build:web # Development build
npm run dev # Vite dev server
npm run build:web # Production build
npm run build:web:test # Test environment build
npm run build:web:prod # Production environment build
npm run build:web:docker # Docker build
npm run build:web:docker # Production Docker build
npm run build:web:docker:test # Test Docker build
npm run build:web:docker:prod # Production Docker build
npm run build:web:serve # Production build, then serve
npm run build:web:serve:test # Test build, then serve
```
**Build Modes**:
- **Development**: Starts Vite dev server with hot reload (default)
- **Production**: Optimized for production with full minification (default)
- **Test**: Optimized for testing with minimal minification
- **Production**: Optimized for production with full minification
- **Development**: Starts Vite dev server with hot reload (`--dev` alone); with `--serve` or `--docker`, builds `dist/` in development mode
**Script Features**: