# μ—λŸ¬ ν•΄κ²°πŸ”‘ 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}
/>

# references

Last Updated: a year ago