50 lines
2.0 KiB
Bash
Executable File
50 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Build script for FileBrowser Widget
|
|
# This script creates a unified distribution in dist/ that works for both:
|
|
# 1. NPM distribution (includes package.json, TypeScript definitions, README)
|
|
# 2. Direct embedding (includes bundled Uppy.js dependencies)
|
|
|
|
set -e
|
|
|
|
echo "🔧 Building FileBrowser Widget..."
|
|
|
|
# Clean previous builds
|
|
echo "🧹 Cleaning previous builds..."
|
|
rm -rf dist/
|
|
|
|
# Build with wasm-pack directly to dist directory
|
|
echo "📦 Building WASM package directly to dist/..."
|
|
wasm-pack build --target web --out-dir dist --release
|
|
|
|
# Download and bundle Uppy.js dependencies for self-contained use
|
|
echo "📦 Downloading Uppy.js dependencies..."
|
|
curl -s "https://releases.transloadit.com/uppy/v3.25.4/uppy.min.js" -o dist/uppy.min.js
|
|
curl -s "https://releases.transloadit.com/uppy/v3.25.4/uppy.min.css" -o dist/uppy.min.css
|
|
|
|
# Verify files were downloaded correctly
|
|
if [ -s dist/uppy.min.js ] && [ -s dist/uppy.min.css ]; then
|
|
echo "✅ Uppy.js bundled successfully ($(wc -c < dist/uppy.min.js) bytes JS, $(wc -c < dist/uppy.min.css) bytes CSS)"
|
|
else
|
|
echo "❌ Failed to download Uppy.js files"
|
|
exit 1
|
|
fi
|
|
|
|
echo "✅ Build complete!"
|
|
echo ""
|
|
echo "📦 Unified distribution created in dist/ with:"
|
|
echo " 🔹 NPM support: package.json, TypeScript definitions, README"
|
|
echo " 🔹 Direct embedding: bundled Uppy.js dependencies"
|
|
echo " 🔹 Self-contained: no external dependencies required"
|
|
echo ""
|
|
echo "🌐 Use 'cargo run --example server' to test the widget"
|
|
echo "📦 Use 'npm publish dist/' to publish to npm"
|
|
echo ""
|
|
|
|
echo "🎯 All widget files ready in dist/ directory:"
|
|
echo " - file_browser_widget.js ($(wc -c < dist/file_browser_widget.js 2>/dev/null || echo '0') bytes)"
|
|
echo " - file_browser_widget_bg.wasm ($(wc -c < dist/file_browser_widget_bg.wasm 2>/dev/null || echo '0') bytes)"
|
|
echo " - uppy.min.js ($(wc -c < dist/uppy.min.js 2>/dev/null || echo '0') bytes)"
|
|
echo " - uppy.min.css ($(wc -c < dist/uppy.min.css 2>/dev/null || echo '0') bytes)"
|
|
echo " - package.json, *.d.ts, README.md (npm metadata)"
|