Skip to content
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

Next.js: Fix for @nx/react/plugin/storybook with SVGs #23210

Merged
merged 4 commits into from Jul 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions code/frameworks/nextjs/src/images/webpack.ts
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,
},
});
};