Astro 7.4: Build Profiling with --timings and Split Image ServicesArticle · digest for October 16
Engineering blueprint of an Astro build process with stage timings and a branch between Sharp and CDN image services
Article2 sections≈ 3 min

Astro 7.4: Build Profiling with --timings and Split Image Services

You've probably hit this frustrating wall: an Astro project grows past a hundred content pages, and suddenly running the build command turns into a painful wait. Instead of the usual fifteen seconds, your terminal freezes for several minutes. What went wrong? Did heavy image processing stall? Is a Vite plugin doing redundant work on every step? Or is a hidden cascade of network calls to an external CMS happening during page prerendering?

Previously, developers had to debug almost blindfolded, sprinkling console.time() calls across config files. If you've been following the ecosystem, you may remember how Astro 7.3: parallel dev servers, runtime logger, and Cloudflare helpers laid the groundwork for deeper runtime monitoring. In Astro 7.4, Matthew Phillips and the team took that idea to its logical conclusion by adding a built-in build profiler.

X-Raying Your Build with --timings

You no longer need third-party plugins or custom hacks for detailed diagnostics. Just run your project build with the new --timings flag:

# Run a profiled project build
npx astro build --timings

Once generation finishes, Astro prints a clean hierarchical tree in your console that breaks down every single phase:

  • reading and validating configuration (resolve config, setup);
  • syncing content collections (content sync);
  • building client bundles and server manifests (client bundle, manifest injection);
  • time spent by each individual Vite plugin;
  • Markdown/MDX processing and metadata parsing.

The most valuable part of the report is the Slowest pages section. The profiler automatically ranks generated routes by render time and calculates both the median and the 95th percentile (p95). In the Astro team's demo, one blog page took 2.10 seconds to build due to sequential async database calls inside a component. As soon as the developers grouped those network requests with Promise.all(), the route's build time dropped to 1.13 seconds. With --timings, hidden traps like this jump right off the screen.

Splitting Image Optimization: Sharp for Build, CDN for SSR

The second major feature in this release solves a long-standing infrastructure trade-off for hybrid deployments.

Previously, the image.service config option was global. If you wanted maximum speed when building static pages, you used the local C-based Sharp module. But if your project also had dynamic SSR routes deployed to Cloudflare Workers or Vercel Edge, you hit a dead end: Sharp's native binaries simply don't run inside lightweight V8 isolates. You had to switch the whole project to slow JS encoders or offload everything to an external Image CDN.

In Astro 7.4, image.service now accepts separate configurations for the build phase and the runtime phase:

import { defineConfig } from 'astro/config';

export default defineConfig({
  image: {
    service: {
      // Fast local Sharp on the CI/CD build server
      build: { entrypoint: 'astro/assets/services/sharp' },
      // External cloud processor for dynamic SSR requests
      runtime: { entrypoint: 'my-custom-image-cdn' },
    },
  },
});
Saving Profiling Reports in CI

The --timings flag writes its diagnostic output to standard stdout. If you want to track build speed trends across commits, redirect the command output into a GitHub Actions text artifact (npx astro build --timings > build-timings.txt) so your monitoring tools can analyze it later.

On top of that, the release brings a native notFound() helper for custom entrypoints, improved image prerendering in the @astrojs/cloudflare adapter, and experimental parallel prerendering in separate Worker threads. You can upgrade with npx @astrojs/upgrade or your package manager.

Want a deep diveVotes help us choose what to break down in detail. This material has 0 votes.
Sources · 2