未验证 提交 6f13956f 编写于 作者: Y Yamagishi Kazutoshi 提交者: GitHub

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)).
上级 5f7c6ae8
...@@ -27,7 +27,7 @@ type ImageProps = { ...@@ -27,7 +27,7 @@ type ImageProps = {
} }
let imageData: any = process.env.__NEXT_IMAGE_OPTS 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 { function computeSrc(src: string, host: string, unoptimized: boolean): string {
if (unoptimized) { if (unoptimized) {
......
...@@ -16,13 +16,13 @@ describe('Next.config.js images prop without default host', () => { ...@@ -16,13 +16,13 @@ describe('Next.config.js images prop without default host', () => {
nextConfig, nextConfig,
`module.exports = { `module.exports = {
images: { images: {
sizes: [480, 1024, 1600],
hosts: { hosts: {
secondary: { secondary: {
path: 'https://examplesecondary.com/images/', path: 'https://examplesecondary.com/images/',
loader: 'cloudinary', loader: 'cloudinary',
}, },
}, },
breakpoints: [480, 1024, 1600],
}, },
}`, }`,
'utf8' 'utf8'
...@@ -46,6 +46,7 @@ describe('Next.config.js images prop without path', () => { ...@@ -46,6 +46,7 @@ describe('Next.config.js images prop without path', () => {
nextConfig, nextConfig,
`module.exports = { `module.exports = {
images: { images: {
sizes: [480, 1024, 1600],
hosts: { hosts: {
default: { default: {
path: 'https://examplesecondary.com/images/', path: 'https://examplesecondary.com/images/',
...@@ -55,7 +56,6 @@ describe('Next.config.js images prop without path', () => { ...@@ -55,7 +56,6 @@ describe('Next.config.js images prop without path', () => {
loader: 'cloudinary', loader: 'cloudinary',
}, },
}, },
breakpoints: [480, 1024, 1600],
}, },
}`, }`,
'utf8' 'utf8'
......
module.exports = { module.exports = {
images: { images: {
sizes: [480, 1024, 1600],
hosts: { hosts: {
default: { default: {
path: 'https://example.com/myaccount/', path: 'https://example.com/myaccount/',
...@@ -10,6 +11,5 @@ module.exports = { ...@@ -10,6 +11,5 @@ module.exports = {
loader: 'cloudinary', loader: 'cloudinary',
}, },
}, },
breakpoints: [480, 1024, 1600],
}, },
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册