From d63869cf5572ebabd4cea98aa8ded531de7ace3d Mon Sep 17 00:00:00 2001 From: David Soerensen <43623966+daves28@users.noreply.github.com> Date: Mon, 26 Jun 2023 10:52:20 -0400 Subject: [PATCH] Update webpack.ts to match changes made in storybook-addon-next This issue https://github.com/RyanClementsHax/storybook-addon-next/issues/100 involving storybook-addon-next and the nx plugin @nx/react/plugin/storybook was resolved https://github.com/RyanClementsHax/storybook-addon-next/pull/101, but that fix didn't make it to this equivalent file here in @storybook/nextjs, making that issue still present when using Storybook 7 and @storybook/nextjs as the framework. --- code/frameworks/nextjs/src/images/webpack.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/code/frameworks/nextjs/src/images/webpack.ts b/code/frameworks/nextjs/src/images/webpack.ts index df6ecacde83e..114d96b5bbcc 100644 --- a/code/frameworks/nextjs/src/images/webpack.ts +++ b/code/frameworks/nextjs/src/images/webpack.ts @@ -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; @@ -30,7 +32,7 @@ const configureStaticImageImport = (baseConfig: WebpackConfig): void => { { loader: require.resolve('@storybook/nextjs/next-image-loader-stub.js'), options: { - filename: assetRule.generator?.filename, + filename: assetRule.generator?.filename ?? fallbackFilename, }, }, ], @@ -40,7 +42,7 @@ const configureStaticImageImport = (baseConfig: WebpackConfig): void => { issuer: /\.(css|scss|sass)$/, type: 'asset/resource', generator: { - filename: assetRule.generator?.filename, + filename: assetRule.generator?.filename ?? fallbackFilename, }, }); };