From 6f13956f122211e96ca7c74aa3522c5722d86b20 Mon Sep 17 00:00:00 2001 From: Yamagishi Kazutoshi Date: Sat, 17 Oct 2020 04:36:31 +0900 Subject: [PATCH] Unify config.image.breakpoints to config.image.sizes (#17953) Unify the confusing `config.images.sizes` ([Image Optimizer](https://github.com/vercel/next.js/discussions/17141)) and `config.images.breakpoints` ([Image Component](https://github.com/vercel/next.js/discussions/16832)). --- packages/next/client/image.tsx | 2 +- .../image-component/bad-next-config/test/index.test.js | 4 ++-- test/integration/image-component/basic/next.config.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/next/client/image.tsx b/packages/next/client/image.tsx index 97a1a11c9e9ccef..6274fcb841fb318 100644 --- a/packages/next/client/image.tsx +++ b/packages/next/client/image.tsx @@ -27,7 +27,7 @@ type ImageProps = { } let imageData: any = process.env.__NEXT_IMAGE_OPTS -const breakpoints = imageData.breakpoints || [640, 1024, 1600] +const breakpoints = imageData.sizes || [640, 1024, 1600] function computeSrc(src: string, host: string, unoptimized: boolean): string { if (unoptimized) { diff --git a/test/integration/image-component/bad-next-config/test/index.test.js b/test/integration/image-component/bad-next-config/test/index.test.js index 9914cc0ca2c1b3f..da8c8963c6fbd47 100644 --- a/test/integration/image-component/bad-next-config/test/index.test.js +++ b/test/integration/image-component/bad-next-config/test/index.test.js @@ -16,13 +16,13 @@ describe('Next.config.js images prop without default host', () => { nextConfig, `module.exports = { images: { + sizes: [480, 1024, 1600], hosts: { secondary: { path: 'https://examplesecondary.com/images/', loader: 'cloudinary', }, }, - breakpoints: [480, 1024, 1600], }, }`, 'utf8' @@ -46,6 +46,7 @@ describe('Next.config.js images prop without path', () => { nextConfig, `module.exports = { images: { + sizes: [480, 1024, 1600], hosts: { default: { path: 'https://examplesecondary.com/images/', @@ -55,7 +56,6 @@ describe('Next.config.js images prop without path', () => { loader: 'cloudinary', }, }, - breakpoints: [480, 1024, 1600], }, }`, 'utf8' diff --git a/test/integration/image-component/basic/next.config.js b/test/integration/image-component/basic/next.config.js index 28c2e06113c5b01..8ada091227bd4a1 100644 --- a/test/integration/image-component/basic/next.config.js +++ b/test/integration/image-component/basic/next.config.js @@ -1,5 +1,6 @@ module.exports = { images: { + sizes: [480, 1024, 1600], hosts: { default: { path: 'https://example.com/myaccount/', @@ -10,6 +11,5 @@ module.exports = { loader: 'cloudinary', }, }, - breakpoints: [480, 1024, 1600], }, }