42 lines
841 B
Bash
Executable File
42 lines
841 B
Bash
Executable File
#!/bin/sh
|
|
set -e
|
|
cd "$(dirname "$0")"
|
|
|
|
# Install esbuild if not present
|
|
if ! command -v esbuild >/dev/null 2>&1; then
|
|
if command -v npx >/dev/null 2>&1; then
|
|
NPX="npx"
|
|
else
|
|
echo "esbuild not found. Install it: npm install -g esbuild"
|
|
exit 1
|
|
fi
|
|
else
|
|
NPX=""
|
|
fi
|
|
|
|
mkdir -p dist
|
|
|
|
# Build JS bundle
|
|
${NPX:+$NPX} esbuild src/app.jsx \
|
|
--bundle \
|
|
--minify \
|
|
--jsx-factory=h \
|
|
--jsx-fragment=Fragment \
|
|
--define:process.env.NODE_ENV=\"production\" \
|
|
--external:preact \
|
|
--outfile=dist/app.js \
|
|
2>/dev/null || \
|
|
${NPX:+$NPX} esbuild src/app.jsx \
|
|
--bundle \
|
|
--minify \
|
|
--jsx-factory=h \
|
|
--jsx-fragment=Fragment \
|
|
--define:process.env.NODE_ENV=\"production\" \
|
|
--outfile=dist/app.js
|
|
|
|
# Copy static files
|
|
cp src/index.html dist/index.html
|
|
cp src/style.css dist/style.css
|
|
|
|
echo "Build complete: web/dist/"
|