Build your project for production. The build command compiles, optimizes, and prepares your app for deployment — whether that's a Node.js server, Vercel, Cloudflare Workers, or a Docker container.
alepha build
Your production-ready app is now in the dist/ folder.
The build process handles everything:
After building, your dist/ folder looks like this:
dist/
├── index.js # Server entry point
├── public/ # Static assets (CSS, JS, images)
│ ├── assets/
│ │ ├── index-abc123.js
│ │ └── index-def456.css
│ └── favicon.ico
└── package.json # Production dependencies
Run your server with:
node dist/index.js
| Flag | Description |
|---|---|
--stats |
Generate build statistics report |
--vercel |
Generate Vercel deployment configuration |
--cloudflare |
Generate Cloudflare Workers configuration |
--docker |
Generate Dockerfile and related files |
--sitemap=<url> |
Generate sitemap.xml with the given base URL |
alepha build
Deploy anywhere that runs Node.js:
# Copy dist/ to your server
scp -r dist/ user@server:/app
# On the server
cd /app && node index.js
alepha build --vercel
Creates a minimal Vercel serverless configuration:
dist/
├── api/
│ └── index.js # Serverless function entry
├── vercel.json # Route rewrites
├── .vercel/
│ └── project.json # Project link (if env vars set)
└── public/
Environment Variables Required
Set
VERCEL_PROJECT_IDandVERCEL_ORG_IDin your.env.productionto automatically link to your Vercel project.
Then deploy:
cd dist && vercel --prod
alepha build --cloudflare
Creates Cloudflare Workers configuration:
dist/
├── main.cloudflare.js # Worker entry point
├── wrangler.jsonc # Wrangler configuration
└── public/ # Static assets (if any)
D1 Database Support
If your
DATABASE_URLstarts withcloudflare-d1:, the D1 binding is automatically configured inwrangler.jsonc.
Then deploy:
cd dist && wrangler deploy
alepha build --docker
Creates a production-ready Dockerfile:
FROM node:20-alpine
WORKDIR /app
COPY dist/ .
EXPOSE 3000
CMD ["node", "index.js"]
Build and run:
docker build -t myapp .
docker run -p 3000:3000 myapp
alepha build --sitemap=https://myapp.com
Generates dist/public/sitemap.xml with all your routes:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://myapp.com/</loc>
</url>
<url>
<loc>https://myapp.com/about</loc>
</url>
<!-- ... -->
</urlset>
alepha build --stats
Generates interactive reports about your bundles:
# View client bundle analysis
open dist/public/stats.html
# View server bundle analysis
open dist/stats.html
The reports show:
Bundle Analysis
Use this to find large dependencies dragging down your bundle size.
The build process respects your environment:
API_URL=https://api.myapp.com
Build-time Variables
Environment variables are embedded at build time. For variables that should differ between environments, use runtime configuration instead.
Advanced build options can be configured in vite.config.ts:
1import alepha from "@alepha/vite"; 2import { defineConfig } from "vite"; 3 4export default defineConfig({ 5 plugins: [ 6 alepha({ 7 // Build options 8 stats: true, 9 vercel: true,10 docker: {11 port: 8080,12 },13 client: {14 sitemap: {15 hostname: "https://myapp.com",16 },17 precompress: true, // Generate .gz and .br files18 },19 }),20 ],21});
Config vs Flags
These defaults are used when you run
alepha buildwithout flags. Command-line flags override config file settings.
The build automatically:
The server build:
node_modules needed in productionfs, path, etc.Single File Deploy
Your production server is a single
index.jsfile. No need to deploynode_modules— everything is bundled.
If you don't have an index.html, the build only creates the server:
alepha build
# → dist/index.js (your server/CLI/worker)
Perfect for:
A typical deployment workflow:
# 1. Verify everything works
alepha verify
# 2. Build for production
alepha build --vercel
# 3. Deploy
cd dist && vercel --prod
Or with Docker:
alepha build --docker
docker build -t myapp:$(git rev-parse --short HEAD) .
docker push myapp:$(git rev-parse --short HEAD)
Run verify first. The alepha verify command catches issues before you build. Don't ship broken code.
Check bundle sizes. Run alepha build --stats periodically. Large bundles slow down your users.
Test the production build locally. After building, run node dist/index.js locally before deploying. Catch issues early.
Environment variables matter. Make sure your production .env is correct. Wrong API URLs are a common deployment bug.