build-editor.sh runs npm install + esbuild from editor-src/, produces: - editor.bundle.js 324.6 KB minified IIFE, sets window.__editor.mount - editor.bundle.css 0 B placeholder (cm6 injects styles at runtime via StyleModule; future extensions that need real CSS can drop into the same file without a template change) - editor.bundle.sha256 integrity hashes The script uses $TMPDIR/npm-cache (override via NPM_CACHE env var) to work around root-owned files in the default ~/.npm cache from older npm versions (the env's `npm ci` rejected the default cache). vendor/README.md documents the rebuild command, the cache override, and the integrity-record convention. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
33 lines
1.1 KiB
Bash
Executable file
33 lines
1.1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
SRC="$HERE/editor-src"
|
|
OUT="$HERE/../l4d2web/static/vendor"
|
|
|
|
cd "$SRC"
|
|
|
|
# Honor an existing $NPM_CACHE override; fall back to $TMPDIR if the
|
|
# default ~/.npm cache is unwritable (root-owned files from older npm
|
|
# versions are a common cause; see ~/.npm/_logs).
|
|
NPM_CACHE="${NPM_CACHE:-$TMPDIR/npm-cache}"
|
|
npm install --cache "$NPM_CACHE"
|
|
|
|
npx esbuild editor-entry.js \
|
|
--bundle --minify \
|
|
--format=iife \
|
|
--global-name=__editor_pkg \
|
|
--outfile="$OUT/editor.bundle.js" \
|
|
--metafile=meta.json \
|
|
--loader:.css=text
|
|
|
|
# cm6 injects its styles at runtime via the StyleModule machinery, so the
|
|
# bundle does not produce a separate .css file. We create an empty
|
|
# editor.bundle.css so the partial template's <link> tag points at
|
|
# something concrete (and future extensions that produce real CSS can
|
|
# drop it in without a template change).
|
|
: > "$OUT/editor.bundle.css"
|
|
|
|
(cd "$OUT" && shasum -a 256 editor.bundle.js editor.bundle.css > editor.bundle.sha256)
|
|
|
|
echo "Built $OUT/editor.bundle.js ($(wc -c < "$OUT/editor.bundle.js") bytes)"
|