Skip to content

fix: check for existence of experimental images #1392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 14, 2022
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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 17 additions & 16 deletions plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,17 @@ const plugin: NetlifyPlugin = {

checkNextSiteHasBuilt({ publish, failBuild })

const {
appDir,
basePath,
i18n,
images,
target,
ignore,
trailingSlash,
outdir,
experimental: {
images: { remotePatterns },
let experimentalRemotePatterns = []
const { appDir, basePath, i18n, images, target, ignore, trailingSlash, outdir, experimental } = await getNextConfig(
{
publish,
failBuild,
},
} = await getNextConfig({
publish,
failBuild,
})
)

if (experimental.images) {
experimentalRemotePatterns = experimental.images.remotePatterns

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[potential boulder] Is it possible that remotePatterns might not be defined even if experimental.images exists?

If there's a dependency on experimentalRemotePatterns needing to be an array, then it might be worth doing the following as an added measure of safety

Suggested change
experimentalRemotePatterns = experimental.images.remotePatterns
experimentalRemotePatterns = experimental.images.remotePatterns ?? []

}

if (isNextAuthInstalled()) {
const config = await getRequiredServerFiles(publish)
Expand Down Expand Up @@ -128,7 +123,13 @@ const plugin: NetlifyPlugin = {
nextConfig: { basePath, i18n },
})

await setupImageFunction({ constants, imageconfig: images, netlifyConfig, basePath, remotePatterns })
await setupImageFunction({
constants,
imageconfig: images,
netlifyConfig,
basePath,
remotePatterns: experimentalRemotePatterns,
})

await generateRedirects({
netlifyConfig,
Expand Down