Build Pipeline Overview
Build Stages
Install Dependencies
Package manager installs all dependencies:Duration: 30-60 seconds (cached after first build)Key dependencies:
astro- Static site generator@notionhq/client- Notion API clientsolid-js,react- UI frameworkstailwindcss- Stylingsharp- Image optimization
Prebuild Hook
The This executes the Notion sync script using
prebuild script runs automatically before the build:package.json
jiti (TypeScript runner).Notion Content Sync
The sync script (Duration: 10-60 seconds (depending on content changes)For each collection, the sync process:
scripts/index.ts) fetches content from Notion:scripts/index.ts
- Queries Notion database for published posts
- Checks which posts need updating (incremental sync)
- Fetches blocks for changed posts
- Converts blocks to Markdown
- Downloads images/assets
- Writes MDX files with frontmatter
Astro Build
Astro builds the static site:Duration: 1-2 minutesBuild process:
- Content collections: Load and validate MDX files
- Static pages: Render all routes at build time
- Component compilation: Astro, React, and Solid.js components
- Asset optimization: Images, CSS, fonts
- Bundle generation: Create optimized JavaScript bundles
- HTML generation: Render final HTML for each page
Optimization Strategies
Incremental Content Sync
The sync process only updates files that changed in Notion:src/lib/notion-download.ts
- Faster builds (only fetch changed content)
- Reduced Notion API usage
- Lower bandwidth consumption
Asset Optimization
- Images
- CSS
- JavaScript
- Fonts
Images are optimized using Astro’s built-in Image component:Optimizations applied:
- Automatic WebP/AVIF conversion
- Responsive image generation
- Lazy loading
- Width/height attributes (no CLS)
public/ during sync.Build Performance
Build Time Breakdown
Cold Build
Total: 3-5 minutes
- Dependencies: 1-2 min
- Notion sync: 30-60 sec
- Astro build: 1-2 min
- Deploy: 30 sec
Incremental Build
Total: 2-3 minutes
- Dependencies: 30 sec (cached)
- Notion sync: 10-20 sec
- Astro build: 1-2 min
- Deploy: 30 sec
Output Size
Environment Variables
Environment variables are used during the build:Build-Time Variables
Build-Time Variables
These are embedded into the static output:Used for:
- Site URL in meta tags
- Canonical URLs
- Open Graph images
Secret Variables
Secret Variables
These are only available during build (not in browser):Used for:
- Notion API authentication
- Database queries
- Asset downloads
Build Hooks
You can customize the build process:Adding Custom Steps
Modifyscripts/index.ts to add custom build steps:
scripts/index.ts
Skipping Notion Sync
For faster local builds, skip Notion sync:scripts/index.ts:
Debugging Build Issues
Check Build Logs
On Vercel, view detailed logs:
- Go to Deployments
- Click the deployment
- View Build Logs tab
- Notion API errors
- MDX parsing errors
- Asset download failures
Caching Strategy
Build Cache
Vercel caches:
node_modules/(dependencies).astro/(Astro build cache)pnpm-lock.yaml(lockfile)
- Changes to
package.json - Manual cache clear
Content Cache
Notion content is cached:
- In
src/content/as MDX files - Incremental sync checks timestamps
- Revalidated on every build
- Changes in Notion (lastEditedTime)
- Manual file deletion
Next Steps
Vercel Deployment
Configure Vercel deployment
Content Sync
Deep dive into Notion sync process