Skip to content

Commit b48a0af

Browse files
Refactor build pipeline for performance and dev output reliability
Replace JS/CSS minifiers with esbuild to significantly reduce build times while preserving outputs. Enable thread-loader by default in both dev and prod with workers chosen dynamically. Keep filesystem cache enabled and make cache compression configurable (favoring uncompressed for faster warm builds on CPU‑bound machines). Add BUILD_PARALLEL to switch between parallel and sequential production variant builds. Improve development outputs: ensure watch‑once builds exit cleanly, use style-loader for faster CSS in dev, keep CSP‑safe external source maps and copy them in dev to avoid 404s, and suppress noisy CSS 404s by skipping only missing assets. Maintainability: consolidate dev CSS placeholder handling and centralize cache‑compression option parsing to reduce duplication and improve readability. Align the Sass fallback error message with the repository string style. No behavioral changes. Additionally, enable dependency caching in GitHub Actions to speed up CI runs. Results on this DO VPS (2 cores, ~4 GiB RAM): - Production first run (cold): ~44s (baseline ~105s) - Production second run (warm): ~19s (baseline ~39s) - Development first run: ~31s; second run: ~29s Times vary by environment; numbers above are for this machine.
1 parent edaf40d commit b48a0af

File tree

5 files changed

+1802
-398
lines changed

5 files changed

+1802
-398
lines changed

.github/copilot-instructions.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,25 @@ Always reference these instructions first and fall back to search or bash comman
1717
- Lint code: `npm run lint` -- uses ESLint.
1818
- Safari build: `npm run build:safari` (see Platform-Specific Instructions for details)
1919

20+
### Build Performance Options
21+
22+
- BUILD_PARALLEL: Toggle parallel build of production variants
23+
- Default: on (parallel). Set to `0` to run sequentially (lower CPU/IO spikes on low-core machines)
24+
- BUILD_THREAD / BUILD_THREAD_WORKERS: Control Babel parallelism via thread-loader
25+
- Default: threads enabled in dev/prod; workers = CPU cores
26+
- Set `BUILD_THREAD=0` to disable; set `BUILD_THREAD_WORKERS=<n>` to override worker count
27+
- BUILD_CACHE_COMPRESSION: Webpack filesystem cache compression
28+
- Default: `0` (no compression) for faster warm builds on CPU‑bound SSD machines
29+
- Options: `0|false|none`, `gzip` (or `brotli` if explicitly desired)
30+
- Affects only `.cache/webpack` size/speed; does not change final artifacts
31+
- BUILD_WATCH_ONCE (dev): When set, `npm run dev` runs a single build and exits (useful for timing)
32+
- BUILD_POOL_TIMEOUT: Override thread-loader production pool timeout (ms)
33+
- Default: `2000`. Increase if workers recycle too aggressively on slow machines/CI
34+
- Source maps (dev): Dev builds emit external `.map` files next to JS bundles for CSP‑safe debugging; production builds disable source maps
35+
- Symlinks: Webpack uses `resolve.symlinks: false` to improve performance and ensure consistent module identity; if you rely on `npm link`/pnpm workspaces, temporarily enable symlink resolution while developing linked packages
36+
37+
Performance defaults: esbuild handles JS/CSS minification. In development, CSS is injected via style-loader; in production, CSS is extracted via MiniCssExtractPlugin. Thread-loader is enabled by default in both dev and prod.
38+
2039
### Build Output Structure
2140

2241
Production build creates multiple variants in `build/` directory:

.github/workflows/pre-release-build.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,20 @@ jobs:
2424
- uses: actions/setup-node@v4
2525
with:
2626
node-version: 20
27+
cache: 'npm'
28+
cache-dependency-path: '**/package-lock.json'
29+
- name: Detect Node major version
30+
run: echo "NODE_MAJOR=$(node -p 'process.versions.node.split(".")[0]')" >> $GITHUB_ENV
2731
- run: npm ci
32+
- name: Cache Webpack filesystem cache
33+
uses: actions/cache@v4
34+
with:
35+
path: |
36+
.cache/webpack
37+
node_modules/.cache/webpack
38+
key: ${{ runner.os }}-node${{ env.NODE_MAJOR }}-webpack-${{ hashFiles('**/package-lock.json', 'build.mjs') }}
39+
restore-keys: |
40+
${{ runner.os }}-node${{ env.NODE_MAJOR }}-webpack-
2841
- run: npm run build
2942

3043
- uses: josStorer/get-current-time@v2

0 commit comments

Comments
 (0)