如何在AstroJS执行构建时将远程图片保存到本地构建产物中?
问题
我有如下AppImage.astro组件:
--- import { Image } from 'astro:assets'; --- <Image src="https://example.com/remote-bird.jpg" alt="A bird." inferSize />
现在希望在生成构建产物时,将这张远程图片保存到构建目录中,并从该目录提供图片服务。
解决方案
在Astro配置文件中添加远程图片域名的允许规则:
export default defineConfig({ image: { remotePatterns: [{ protocol: 'https', hostname: 'example.com', // 你的图片源域名 }], } });
内容的提问来源于stack exchange,提问作者mani
相关产品推荐
相关产品推荐

