【发布时间】:2021-10-04 00:17:33
【问题描述】:
我正在使用 next.js 导出来创建一个托管在谷歌云存储上的静态 html 导出。
我在 next.js 配置中使用此解决方法。
images: {
loader: 'imgix',
path: 'https://noop/',
},
我需要如何配置外部加载程序,例如imgix 可以正常工作吗?
【问题讨论】:
我正在使用 next.js 导出来创建一个托管在谷歌云存储上的静态 html 导出。
我在 next.js 配置中使用此解决方法。
images: {
loader: 'imgix',
path: 'https://noop/',
},
我需要如何配置外部加载程序,例如imgix 可以正常工作吗?
【问题讨论】:
images: {
deviceSizes: [320, 420, 768, 1024, 1200],
loader: "imgix",
path: "https://<account>.imgix.net/",
},
然后在你的组件中,
const imgSrc = "random.png";
<Image
src={imgSrc} // <= https://<account>.imgix.net/random.png
width={300}
height={300}
alt={alt}
/>
images: {
deviceSizes: [320, 420, 768, 1024, 1200],
loader: "imgix",
path: "",
},
然后在你的组件中,
const imgSrc = "https://<imagesource-domain>/random.png";
<Image
src={imgSrc} // <= https://<imagesource-domain>/random.png
width={300}
height={300}
alt={alt}
/>
【讨论】: