Skip to content

Commit

Permalink
Update webpack.ts to match changes made in storybook-addon-next
Browse files Browse the repository at this point in the history
This issue RyanClementsHax/storybook-addon-next#100 involving storybook-addon-next and the nx plugin @nx/react/plugin/storybook was resolved  RyanClementsHax/storybook-addon-next#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.
  • Loading branch information
daves28 committed Jun 26, 2023
1 parent 829c084 commit d63869c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions code/frameworks/nextjs/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 @@ -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,
},
},
],
Expand All @@ -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,
},
});
};

0 comments on commit d63869c

Please sign in to comment.