Unverified Commit 6fcb518f authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub
parent 9255da25
...@@ -115,6 +115,8 @@ function nextImageLoader(this: any, content: Buffer) { ...@@ -115,6 +115,8 @@ function nextImageLoader(this: any, content: Buffer) {
content, content,
null null
) )
} else {
this.emitFile(interpolatedName, content, null)
} }
return `export default ${stringifiedData};` return `export default ${stringifiedData};`
......
import testJPG from '../public/test.jpg'
import Image from 'next/image'
export default function StaticImg() {
return (
<Image
id="dynamic-loaded-static-jpg"
src={testJPG}
alt="dynamic-loaded-static-jpg"
/>
)
}
import dynamic from 'next/dynamic'
const DynamicStaticImg = dynamic(() => import('../components/static-img'), {
ssr: false,
})
export default () => {
return (
<div>
<DynamicStaticImg />
</div>
)
}
...@@ -4,6 +4,7 @@ import cheerio from 'cheerio' ...@@ -4,6 +4,7 @@ import cheerio from 'cheerio'
import validateHTML from 'html-validator' import validateHTML from 'html-validator'
import { import {
check, check,
fetchViaHTTP,
findPort, findPort,
getRedboxHeader, getRedboxHeader,
hasRedbox, hasRedbox,
...@@ -1114,6 +1115,14 @@ function runTests(mode) { ...@@ -1114,6 +1115,14 @@ function runTests(mode) {
).toBe('1px 2px') ).toBe('1px 2px')
}) })
it('should emit image for next/dynamic with non ssr case', async () => {
let browser = await webdriver(appPort, '/dynamic-static-img')
const img = await browser.elementById('dynamic-loaded-static-jpg')
const src = await img.getAttribute('src')
const { status } = await fetchViaHTTP(appPort, src)
expect(status).toBe(200)
})
// Tests that use the `unsized` attribute: // Tests that use the `unsized` attribute:
if (mode !== 'dev') { if (mode !== 'dev') {
it('should correctly rotate image', async () => { it('should correctly rotate image', async () => {
......
import testJPG from '../public/test.jpg'
import Image from 'next/image'
export default function StaticImg() {
return (
<Image
id="dynamic-loaded-static-jpg"
src={testJPG}
alt="dynamic-loaded-static-jpg"
/>
)
}
import dynamic from 'next/dynamic'
const DynamicStaticImg = dynamic(() => import('../components/static-img'), {
ssr: false,
})
export default () => {
return (
<div>
<DynamicStaticImg />
</div>
)
}
...@@ -4,6 +4,7 @@ import cheerio from 'cheerio' ...@@ -4,6 +4,7 @@ import cheerio from 'cheerio'
import validateHTML from 'html-validator' import validateHTML from 'html-validator'
import { import {
check, check,
fetchViaHTTP,
findPort, findPort,
getRedboxHeader, getRedboxHeader,
hasRedbox, hasRedbox,
...@@ -1094,6 +1095,15 @@ function runTests(mode) { ...@@ -1094,6 +1095,15 @@ function runTests(mode) {
await getComputedStyle(browser, 'img-blur', 'background-position') await getComputedStyle(browser, 'img-blur', 'background-position')
).toBe('1px 2px') ).toBe('1px 2px')
}) })
it('should emit image for next/dynamic with non ssr case', async () => {
let browser = await webdriver(appPort, '/dynamic-static-img')
const img = await browser.elementById('dynamic-loaded-static-jpg')
const src = await img.getAttribute('src')
const { status } = await fetchViaHTTP(appPort, src)
expect(status).toBe(200)
})
describe('Fill-mode tests', () => { describe('Fill-mode tests', () => {
let browser let browser
beforeAll(async () => { beforeAll(async () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment