# μλ¬ ν΄κ²°π Next.js next export λ°°ν¬ μ image loader μλ¬
Next.js νλ‘μ νΈ κ²°κ³Όλ¬Όμ S3λ‘ λ°°ν¬νλ μ€ image loaderμμ λ€μκ³Ό κ°μ μλ¬κ° λ°μνλ€.
Error: Image Optimization using Next.js' default loader is not compatible with next export.
Possible solutions:
- Use next start, which starts the Image Optimization API.
- Use Vercel to deploy, which supports Image Optimization.
- Configure a third-party loader in next.config.js.
next/Image
μμ μν¬νΈνλ <Image />
μ»΄ν¬λνΈμ default loaderκ° next exportμμλ μ§μλμ§ μκΈ° λλ¬Έμ λ°μνλ μλ¬λ€.
λ°λΌμ λ€μκ³Ό κ°μ μ€μ μ΄ μΆκ°λ‘ νμνλ€.
// next.config.js
module.exports = {
images: {
loader: 'imgix',
domain: [process.env.CLIENT], // μ΄λ―Έμ§ λλ©μΈ
},
}
// utils/imgLoader.ts
export const imgLoader = ({
src,
width,
quality,
}: {
src: string;
width: number;
quality?: number;
}): string => {
return `${CLIENT}${src}?w=${width}&q=${quality || 75}`;
};
κ·Έλ¦¬κ³ Image
μ»΄ν¬λνΈ μ¬μ© μ μλμ κ°μ΄ loaderλ₯Ό μ μ©νμ¬ μμ±νλ€.
<Image
loader={({ src, width, quality }: ImageLoaderProps) => imgLoader({ src, width, quality })}
src="/assets/images/arrow.png"
blurDataURL="/assets/images/arrow.png"
placeholder="blur"
alt="arrow"
width={192}
height={192}
/>