2026-05-22 · 4 min
Astro 6 Build Time: 8 Detik di Laptop Karawaci
Saya pindah klien terakhir dari Astro 5.18 ke Astro 6.3 minggu lalu. Build time turun dari 12 detik ke 8 detik di laptop saya (MBA M2, 16GB). Inilah yang berubah.
Setup project
Site: directory bisnis lokal Tangerang dengan 120 markdown posts. Dependencies: Astro 6.3, @astrojs/sitemap, astro-og-canvas (untuk 120 OG image), @astrojs/rss. Build target: static (dist/ deploy ke CF Pages).
Benchmark
Saya jalankan bun run build 5 kali, ambil median:
| Astro version | Total build | Image gen | HTML output |
|---|---|---|---|
| 5.18 | 12.3s | 6.8s | 4.2s |
| 6.0 | 11.1s | 5.4s | 4.3s |
| 6.3 | 8.1s | 4.2s | 2.8s |
Improvement utama di 6.x:
- Faster Vite plugin pipeline: rolldown bundler partial integration. Belum default tapi default di 6.5 yang akan keluar.
- Image generation parallel: astro-og-canvas auto-detect CPU count, jalankan parallel. Di MBA M2 (8 core), parallel 6 worker.
- HTML output streaming: Astro 6 stream HTML write ke disk lebih cepat. ~30% improvement.
Optimisasi yang saya lakukan
1. Pre-build asset
Image static yang tidak berubah saya pre-generate dan commit ke public/. Build process tidak generate ulang.
2. Reduce content collection overhead
Astro 5 punya overhead per content entry karena schema validation Zod jalan setiap entry. Astro 6 cache schema compilation. Tidak ada code change required.
3. Disable Shiki untuk preview build
Untuk preview deployments yang butuh quick check:
# Skip Shiki syntax highlight (saving ~1s)
ASTRO_SKIP_SHIKI=1 bun run build:preview
build:preview script di package.json:
{
"scripts": {
"build": "astro build",
"build:preview": "astro build --no-progressbar"
}
}
4. Image format choice
OG image generation paling slow. Saya optimize:
// astro.config.mjs
import { defineConfig } from 'astro/config';
export default defineConfig({
image: {
service: { entrypoint: 'astro/assets/services/sharp' },
// Pre-resolve image cache to filesystem
domains: ['cdn.example.com'],
},
});
PNG → WebP konversi 30% lebih cepat di sharp 0.34 vs 0.33.
Yang tidak bisa dioptimize lebih
-
DNS resolution dari content fetch: Markdown yang reference image dari URL external trigger DNS + HTTP fetch saat build. Pre-cache lokal kalau mungkin.
-
Heavy syntax highlight: Shiki untuk code block, parsing besar. Pertimbangkan code block tanpa highlight untuk dev posts (less critical).
-
Build worker count: untuk laptop di Karawaci dengan AC kantor di Karawaci yang fluktuatif voltase, M2 throttle thermal sekitar 10-15% saat building 8+ menit terus. Untuk CI/CD: lebih konsisten karena server actively cooled.
CF Pages build time
Di Cloudflare Pages remote builder: 18 detik vs 8 detik lokal saya. Network upload + S3 cache fetch overhead.
Saving: kalau saya commit hanya markdown content (no asset change), incremental build di CF Pages: ~5 detik. Cukup quick.
Kesimpulan
Astro 6 worth upgrade untuk speed alone. Setup migration: 30 menit (mostly read changelog). Zero breaking change untuk site sederhana saya. Untuk site dengan banyak custom integration: cek compat first.
Build time 8 detik di laptop = 30 deploy per jam practical. Saya tidak butuh sebanyak itu, tapi senang knowing edit-build-test loop tidak nge-block flow.
Ditulis oleh Reza Pradipta