Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix bug
  • Loading branch information
styfle committed Nov 2, 2021
commit 34258bb85d7d674f8ae38d7f63c030037151e6a7
2 changes: 1 addition & 1 deletion packages/next/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1682,7 +1682,7 @@ export default async function getBaseWebpackConfig(
productionBrowserSourceMaps: config.productionBrowserSourceMaps,
future: config.future,
experimental: config.experimental,
disableStaticImages: config.disableStaticImages,
disableStaticImages: config.images.disableStaticImages,
})

// @ts-ignore Cache exists
Expand Down
5 changes: 3 additions & 2 deletions packages/next/build/webpack/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ export async function build(
experimental,
}

let fn = pipe(base(ctx), css(ctx))
let fns = [base(ctx), css(ctx)]
if (!disableStaticImages) {
fn = pipe(fn, images(ctx))
fns.push(images(ctx))
}
const fn = pipe(...fns)
return fn(config)
}
14 changes: 11 additions & 3 deletions test/integration/invalid-document-image-import/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,23 @@ describe('Invalid static image import in _document', () => {
expect(stderr).toMatch(/Location:.*pages[\\/]_document\.js/)
})

it('Should build without error when disableStaticImages in next.config.js', async () => {
it('Should fail to build when disableStaticImages in next.config.js', async () => {
nextConfig.write(`
module.exports = {
images: {
disableStaticImages: true
}
}
`)
const { code } = await nextBuild(appDir, [], {})
expect(code).toBe(0)
const { code, stderr } = await nextBuild(appDir, [], {
stderr: true,
})
expect(code).not.toBe(0)
expect(stderr).toMatch(
/You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file/
)
expect(stderr).not.toMatch(
/Images.*cannot.*be imported within.*pages[\\/]_document\.js/
)
})
})