Skip to content

Commit

Permalink
Merge pull request #23210 from daves28/patch-1
Browse files Browse the repository at this point in the history
Next.js: Resolving compilation issues when using @nx/react/plugin/storybook with stories that contain SVGs

(cherry picked from commit 8704b36)
  • Loading branch information
valentinpalkovic authored and storybook-bot committed Jul 11, 2023
1 parent 6915887 commit 4965513
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions code/frameworks/nextjs/src/images/webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export const configureImages = (baseConfig: WebpackConfig, nextConfig: NextConfi
configureImageDefaults(baseConfig);
};

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

const configureImageDefaults = (baseConfig: WebpackConfig): void => {
const version = getNextjsVersion();
const resolve = baseConfig.resolve ?? {};
Expand Down Expand Up @@ -58,7 +60,7 @@ const configureStaticImageImport = (baseConfig: WebpackConfig, nextConfig: NextC
{
loader: require.resolve('@storybook/nextjs/next-image-loader-stub.js'),
options: {
filename: assetRule.generator?.filename,
filename: assetRule.generator?.filename ?? fallbackFilename,
nextConfig,
},
},
Expand All @@ -69,7 +71,7 @@ const configureStaticImageImport = (baseConfig: WebpackConfig, nextConfig: NextC
issuer: /\.(css|scss|sass)$/,
type: 'asset/resource',
generator: {
filename: assetRule.generator?.filename,
filename: assetRule.generator?.filename ?? fallbackFilename,
},
});
};

0 comments on commit 4965513

Please sign in to comment.