main
1#!/bin/bash
2set -e
3
4echo "๐ฆ Bundling React app to single HTML artifact..."
5
6# Check if we're in a project directory
7if [ ! -f "package.json" ]; then
8 echo "โ Error: No package.json found. Run this script from your project root."
9 exit 1
10fi
11
12# Check if index.html exists
13if [ ! -f "index.html" ]; then
14 echo "โ Error: No index.html found in project root."
15 echo " This script requires an index.html entry point."
16 exit 1
17fi
18
19# Install bundling dependencies
20echo "๐ฆ Installing bundling dependencies..."
21pnpm add -D parcel @parcel/config-default parcel-resolver-tspaths html-inline
22
23# Create Parcel config with tspaths resolver
24if [ ! -f ".parcelrc" ]; then
25 echo "๐ง Creating Parcel configuration with path alias support..."
26 cat > .parcelrc << 'EOF'
27{
28 "extends": "@parcel/config-default",
29 "resolvers": ["parcel-resolver-tspaths", "..."]
30}
31EOF
32fi
33
34# Clean previous build
35echo "๐งน Cleaning previous build..."
36rm -rf dist bundle.html
37
38# Build with Parcel
39echo "๐จ Building with Parcel..."
40pnpm exec parcel build index.html --dist-dir dist --no-source-maps
41
42# Inline everything into single HTML
43echo "๐ฏ Inlining all assets into single HTML file..."
44pnpm exec html-inline dist/index.html > bundle.html
45
46# Get file size
47FILE_SIZE=$(du -h bundle.html | cut -f1)
48
49echo ""
50echo "โ
Bundle complete!"
51echo "๐ Output: bundle.html ($FILE_SIZE)"
52echo ""
53echo "You can now use this single HTML file as an artifact in Claude conversations."
54echo "To test locally: open bundle.html in your browser"