| | #!/bin/bash |
| | set -e |
| |
|
| | echo "π¦ Bundling React app to single HTML artifact..." |
| |
|
| | |
| | if [ ! -f "package.json" ]; then |
| | echo "β Error: No package.json found. Run this script from your project root." |
| | exit 1 |
| | fi |
| |
|
| | |
| | if [ ! -f "index.html" ]; then |
| | echo "β Error: No index.html found in project root." |
| | echo " This script requires an index.html entry point." |
| | exit 1 |
| | fi |
| |
|
| | |
| | echo "π¦ Installing bundling dependencies..." |
| | pnpm add -D parcel @parcel/config-default parcel-resolver-tspaths html-inline |
| |
|
| | |
| | if [ ! -f ".parcelrc" ]; then |
| | echo "π§ Creating Parcel configuration with path alias support..." |
| | cat > .parcelrc << 'EOF' |
| | { |
| | "extends": "@parcel/config-default", |
| | "resolvers": ["parcel-resolver-tspaths", "..."] |
| | } |
| | EOF |
| | fi |
| |
|
| | |
| | echo "π§Ή Cleaning previous build..." |
| | rm -rf dist bundle.html |
| |
|
| | |
| | echo "π¨ Building with Parcel..." |
| | pnpm exec parcel build index.html --dist-dir dist --no-source-maps |
| |
|
| | |
| | echo "π― Inlining all assets into single HTML file..." |
| | pnpm exec html-inline dist/index.html > bundle.html |
| |
|
| | |
| | FILE_SIZE=$(du -h bundle.html | cut -f1) |
| |
|
| | echo "" |
| | echo "β
Bundle complete!" |
| | echo "π Output: bundle.html ($FILE_SIZE)" |
| | echo "" |
| | echo "You can now use this single HTML file as an artifact in Claude conversations." |
| | echo "To test locally: open bundle.html in your browser" |