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

fix: nextjs images in storybook #684

Merged
merged 1 commit into from May 4, 2022
Merged

fix: nextjs images in storybook #684

merged 1 commit into from May 4, 2022

Conversation

mattrosno
Copy link
Member

Following this related fix from 13 days ago: storybookjs/storybook#17950 (comment)

This PR changes how Storybook processes Next.js images by using an alias instead of attempting to redefine the next/image component.

Changelog

New

  • NA

Changed

  • Storybook config

Removed

  • NA

Testing / reviewing

The assets page story should now work (it has Next.js images).

import clsx from 'clsx'

// `node_modules` import is necessary to not create a cyclically resolving alias
import Image from '../../../node_modules/next/image'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jdharvey-ibm this isn't pretty but I don't know a better way.

@sonarcloud
Copy link

sonarcloud bot commented May 4, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link
Member

@alisonjoseph alisonjoseph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed assets page and images load in storybook. Thanks Matt! 👍

@alisonjoseph alisonjoseph merged commit 26f9025 into main May 4, 2022
@alisonjoseph alisonjoseph deleted the fix/storybook-images branch May 4, 2022 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants