Skip to content

Commit d9cc0eb

Browse files
Refactor build pipeline for performance and dev output reliability
Replace JS/CSS minifiers with esbuild to reduce build times while preserving outputs. Enable `thread-loader` by default in dev and production. Choose workers dynamically (based on CPU cores) and allow overrides via environment variables. Keep filesystem cache enabled and make cache compression configurable, defaulting to uncompressed for faster warm builds on CPU-bound machines. Add BUILD_PARALLEL toggle (default on) to switch between parallel and sequential production variant builds. Ensure watch-once dev builds exit cleanly by awaiting async output work. Adopt `sass-embedded` for SASS processing. In development, use `style-loader` to speed up CSS/SCSS compilation while keeping production outputs unchanged. Maintain CSP-safe source maps for extension contexts; copy external maps in dev to avoid 404s; suppress CSS 404 noise in dev outputs by skipping only missing CSS. Additionally, dependency caching has been added to the GitHub Actions workflow to accelerate CI/CD 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 3768a06 commit d9cc0eb

File tree

5 files changed

+1767
-395
lines changed

5 files changed

+1767
-395
lines changed

.github/copilot-instructions.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,24 @@ 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+
35+
Performance defaults: esbuild handles JS/CSS minification. In development, CSS is injected via style-loader;
36+
in production, CSS is extracted via MiniCssExtractPlugin. Thread-loader is enabled by default in both dev and prod.
37+
2038
### Build Output Structure
2139

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

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

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

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

0 commit comments

Comments
 (0)