惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

阮一峰的网络日志
阮一峰的网络日志
The GitHub Blog
The GitHub Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
雷峰网
雷峰网
U
Unit 42
Y
Y Combinator Blog
I
InfoQ
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
量子位
Microsoft Security Blog
Microsoft Security Blog
B
Blog
The Cloudflare Blog
F
Fortinet All Blogs
Google DeepMind News
Google DeepMind News
MyScale Blog
MyScale Blog
C
Check Point Blog
S
SegmentFault 最新的问题
爱范儿
爱范儿
博客园 - 叶小钗
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Hugging Face - Blog
Hugging Face - Blog
罗磊的独立博客
T
Tailwind CSS Blog

The Astro Blog

Astro 6.4 Astro 6.3 Starlight 0.39 Astro 6.2 What's new in Astro - April 2026 What's new in Astro - March 2026 Astro 6.1 CloudCannon Joins Astro as an Official CMS Partner Astro 6.0 What's new in Astro - February 2026 What's new in Astro - January 2026 Astro 5.17 Supporting the future of Astro The Astro Technology Company joins Cloudflare Astro 6 Beta What's new in Astro - December 2025 What's new in Astro - November 2025 Astro 5.16 Stainless Sponsors Astro, Launches Astro-Powered Docs Platform What's new in Astro - October 2025 Astro 5.15 Spirit of Astro: meet the winning designs What's new in Astro - September 2025 Astro 5.14 Cloudflare Donates $150,000 to Support Astro's Open Source Mission Webflow Donates $150,000 to Support Astro's Open Source Mission Mux: Our Official Video Partner Unleashing creativity: How CodeTV built a video streaming platform with Astro and Mux | Astro What's new in Astro - August 2025 Astro 5.13
Astro 2.2
Matthew Phillips · 2023-04-05 · via The Astro Blog

Astro 2.2 is out! Included in this release are:

  • CDN support for assets: You can now deploy your assets to an external CDN, and Astro will load them from there.
  • image() schema helper API change: (experimental) The image() helper has been moved to be inline with the schema definition.

Additionally, Astro 2.2 includes 8 patch changes and was released alongside 8 integrations with patch releases.

Run npm i astro@latest to upgrade to the latest version.

CDN support

In 2.2 you can now configure Astro to point to a CDN in order to load your assets. In your Astro config:

import { defineConfig } from "astro/config"

export default defineConfig({

build: {

assetsPrefix: "https://cdn.example.com",

},

})

The links for any assets, scripts, and stylesheets after running astro build will be prefixed with the configured URL. This applies to both SSG and SSR modes.

<link rel="stylesheet" href="https://cdn.example.com/_astro/global.css" />

The assets are still built to your dist/ folder, like always. You will need to configure your deployment scripts to deploy dist/_astro/ to your CDN.

image() schema API change

In 2.2 the image() schema helper in the experimental assets API has been moved to a callback where the schema is defined.

import { defineCollection, z } from "astro:content"

const blog = defineCollection({

schema: ({ image }) =>

z.object({

image: image().refine((img) => img.width >= 200, {

message: "image too small",

}),

}),

})

Previously, image() was imported directly from 'astro:content'. However, this created bugs where Astro was not able to correctly resolve relative image assets defined in the frontmatter. Providing the helper as a callback aligns with how Zod suggests implementing contextual references.

This new callback based schema assignment is currently only available with experimental assets enabled. If you are not using the image() helper, you can continue to assign the schemas directly to the schema property on the collection.

Try Astro 2.2

Thank you to everyone who contributed to this outstanding release. In addition to these new features, there were also several bug fixes throughout the core packages and integrations. See the complete release notes to learn more.