Deployment
Deploy your PACE.js app to production.
Build for Production
1. Optimize Bundle
npm run buildThis creates optimized production files:
dist/
├── index.html
├── assets/
│ ├── pace.min.js # Minified PACE.js
│ ├── pace.min.css # Minified CSS
│ └── app.js # Your app code
└── products.json2. Test Production Build
npm run previewOpen http://localhost:4173 and verify everything works.
Deployment Platforms
Netlify (Recommended)
Method 1: Drag & Drop
- Build your app:
npm run build - Go to Netlify Drop
- Drag
dist/folder - Done! 🎉
Method 2: Git Integration
# Install Netlify CLI
npm install -g netlify-cli
# Login
netlify login
# Initialize
netlify init
# Deploy
netlify deploy --prodnetlify.toml:
[build]
command = "npm run build"
publish = "dist"
[[redirects]]
from = "/*"
to = "/index.html"
status = 200Vercel
# Install Vercel CLI
npm install -g vercel
# Deploy
vercelvercel.json:
{
"buildCommand": "npm run build",
"outputDirectory": "dist",
"rewrites": [
{ "source": "/(.*)", "destination": "/index.html" }
]
}Cloudflare Pages
# Install Wrangler
npm install -g wrangler
# Login
wrangler login
# Deploy
wrangler pages deploy distwrangler.toml:
name = "pace-app"
compatibility_date = "2024-01-01"
[build]
command = "npm run build"
[build.upload]
format = "directory"
dir = "dist"GitHub Pages
Using GitHub Actions
.github/workflows/deploy.yml:
name: Deploy to GitHub Pages
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm install
- name: Build
run: npm run build
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./distManual Deployment
npm run build
npm install -g gh-pages
gh-pages -d distAWS S3 + CloudFront
# Build
npm run build
# Upload to S3
aws s3 sync dist/ s3://your-bucket-name --delete
# Invalidate CloudFront cache
aws cloudfront create-invalidation --distribution-id YOUR_DIST_ID --paths "/*"Docker
Dockerfile:
FROM node:18-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]nginx.conf:
server {
listen 80;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
# Enable gzip
gzip on;
gzip_types text/css application/javascript application/json;
}Build & Run:
docker build -t pace-app .
docker run -p 8080:80 pace-appEnvironment Variables
Production API Keys
Never commit API keys! Use environment variables:
Netlify
netlify env:set CLAUDE_API_KEY your-key-hereOr in Netlify UI: Site Settings → Environment Variables
Vercel
vercel env add CLAUDE_API_KEYOr in Vercel UI: Project Settings → Environment Variables
Cloudflare Pages
In Cloudflare dashboard: Pages → Settings → Environment Variables
GitHub Actions
Repository Settings → Secrets → Actions
env:
CLAUDE_API_KEY: ${{ secrets.CLAUDE_API_KEY }}Performance Optimization
1. Enable Compression
Most platforms enable gzip by default. Verify:
curl -H "Accept-Encoding: gzip" -I https://your-site.comLook for: Content-Encoding: gzip
2. Set Cache Headers
Netlify (netlify.toml):
[[headers]]
for = "/*.js"
[headers.values]
Cache-Control = "public, max-age=31536000, immutable"
[[headers]]
for = "/*.css"
[headers.values]
Cache-Control = "public, max-age=31536000, immutable"
[[headers]]
for = "/index.html"
[headers.values]
Cache-Control = "public, max-age=0, must-revalidate"Nginx:
location ~* \.(js|css)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
location = /index.html {
expires off;
add_header Cache-Control "no-cache, must-revalidate";
}3. Use CDN
All recommended platforms include CDN automatically:
- ✅ Netlify CDN
- ✅ Vercel Edge Network
- ✅ Cloudflare CDN
- ✅ AWS CloudFront
4. Lazy Load Products
const pace = new PACE({
container: '#app',
products: async () => {
const response = await fetch('/api/products')
return await response.json()
}
})Custom Domain
Netlify
- Go to Domain Settings
- Add custom domain
- Configure DNS:
CNAME www your-site.netlify.app A @ 75.2.60.5
Vercel
- Go to Project Settings → Domains
- Add domain
- Configure DNS:
CNAME www cname.vercel-dns.com A @ 76.76.21.21
Cloudflare Pages
- Go to Custom Domains
- Add domain (automatically configured if using Cloudflare DNS)
SSL/HTTPS
All recommended platforms provide free SSL automatically:
- ✅ Netlify - Let's Encrypt
- ✅ Vercel - Let's Encrypt
- ✅ Cloudflare - Free SSL
- ✅ GitHub Pages - GitHub SSL
Monitoring
Error Tracking
Sentry
import * as Sentry from "@sentry/browser"
Sentry.init({
dsn: "YOUR_SENTRY_DSN",
integrations: [new Sentry.BrowserTracing()],
tracesSampleRate: 1.0,
})
pace.on('error', ({ error }) => {
Sentry.captureException(error)
})Analytics
Google Analytics
pace.on('navigate', (route) => {
gtag('config', 'GA_MEASUREMENT_ID', {
page_path: `/#${route}`
})
})
pace.on('product:select', ({ product }) => {
gtag('event', 'product_view', {
product_id: product.id,
product_name: product.name
})
})Uptime Monitoring
- UptimeRobot (free)
- Pingdom
- StatusCake
Deployment Checklist
Pre-Deploy
- [ ] Run
npm run build - [ ] Test production build locally
- [ ] Set environment variables
- [ ] Update API endpoints for production
- [ ] Test on mobile devices
- [ ] Run accessibility audit
- [ ] Check performance (Lighthouse)
Deploy
- [ ] Deploy to staging first
- [ ] Test staging thoroughly
- [ ] Deploy to production
- [ ] Verify production works
Post-Deploy
- [ ] Check error tracking
- [ ] Monitor analytics
- [ ] Test critical user flows
- [ ] Verify SSL certificate
- [ ] Test custom domain
- [ ] Update DNS if needed
Rollback Strategy
Netlify
# View deployments
netlify deploy:list
# Rollback to previous
netlify rollbackVercel
# List deployments
vercel ls
# Promote deployment to production
vercel promote [deployment-url]GitHub Pages
# Revert to previous commit
git revert HEAD
git push origin mainZero-Downtime Deployment
All recommended platforms support atomic deployments:
- New version builds
- Health checks pass
- Traffic switches instantly
- Old version remains if rollback needed
No downtime! 🎉
Multi-Environment Setup
Development
// .env.development
CLAUDE_API_KEY=sk-ant-dev-...
API_URL=http://localhost:3000Staging
// .env.staging
CLAUDE_API_KEY=sk-ant-staging-...
API_URL=https://api-staging.example.comProduction
// .env.production
CLAUDE_API_KEY=sk-ant-prod-...
API_URL=https://api.example.comDeploy PACE.js with confidence! 🚀