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 1/2] 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, }, }); }; From 7c5fe03c945669a86364a0c725a0040b160b562c Mon Sep 17 00:00:00 2001 From: Valentin Palkovic Date: Fri, 7 Jul 2023 16:18:23 +0200 Subject: [PATCH 2/2] Add semicolon --- code/frameworks/nextjs/src/images/webpack.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/frameworks/nextjs/src/images/webpack.ts b/code/frameworks/nextjs/src/images/webpack.ts index db01a0ed7c15..6f1f24208563 100644 --- a/code/frameworks/nextjs/src/images/webpack.ts +++ b/code/frameworks/nextjs/src/images/webpack.ts @@ -9,7 +9,7 @@ export const configureImages = (baseConfig: WebpackConfig, nextConfig: NextConfi configureImageDefaults(baseConfig); }; -const fallbackFilename = 'static/media/[path][name][ext]' +const fallbackFilename = 'static/media/[path][name][ext]'; const configureImageDefaults = (baseConfig: WebpackConfig): void => { const version = getNextjsVersion();