Skip to content

Commit

Permalink
fix: fix undefined "generator.filename" option
Browse files Browse the repository at this point in the history
  • Loading branch information
anatoo committed Jul 19, 2022
1 parent 583e145 commit ed01a74
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/images/webpack.ts
Expand Up @@ -7,6 +7,8 @@ export const configureImages = (baseConfig: WebpackConfig): void => {
addScopedAlias(baseConfig, 'next/image')
}

const fallbackFilename = 'static/media/[path][name][ext]'

const configureStaticImageImport = (baseConfig: WebpackConfig): void => {
const version = getNextjsVersion()
if (semver.lt(version, '11.0.0')) return
Expand All @@ -26,7 +28,7 @@ const configureStaticImageImport = (baseConfig: WebpackConfig): void => {
{
loader: require.resolve('./next-image-loader-stub'),
options: {
filename: assetRule.generator?.filename
filename: assetRule.generator?.filename ?? fallbackFilename
}
}
]
Expand All @@ -36,7 +38,7 @@ const configureStaticImageImport = (baseConfig: WebpackConfig): void => {
issuer: /\.(css|scss|sass)$/,
type: 'asset/resource',
generator: {
filename: assetRule.generator?.filename
filename: assetRule.generator?.filename ?? fallbackFilename
}
})
}

0 comments on commit ed01a74

Please sign in to comment.