StaticImage component from gatsby-plugin-image does not work with storybook #31766
Replies: 3 comments 4 replies
-
|
You could try these new instructions: #31653 |
Beta Was this translation helpful? Give feedback.
-
|
@LekoArts This is not in Storybook's corner, sorry. You guys have a docs page that claims compatibility with Storybook. They now officially use Webpack 5, so your team should definitely reopen this as a legit Gatsby issue and help get a solution out. Unless others are using StaticImage successfully with Storybook -- is that the case? Having just spun up a fresh project and tried, I can vouch that it doesn't work. I get the same error as listed on this discussion, this Stack Overflow post which also is unanswered, and since it was suggested to go bother the community maintainer of the addon, my issue there (not their problem). Are you claiming that someone has actually checked your current Storybook docs page and tried out the basic Gatsby Image Plugin use cases, and it works? Because it not, closing this prematurely and trying to push it off on others isn't fair at all, nor is it becoming of a $50M funded company. People are losing a lot of painful time over something (that may be, is it?) wrong in Gatsby's docs. More importantly if you'd shoot this to an engineer to look into as valid or not before just closing it and pushing it down, maybe you'd find that there's a pretty low lift -- just updating the docs a little or something. (And while I'm at it: having to petition unjustly closed issues just to get heard is for the birds.) |
Beta Was this translation helpful? Give feedback.
-
|
@LekoArts Thank you so much for updating the docs to help others avoid a time sink on this! I understand your points and appreciate your thoughtful reply and action. I'm sorry if my frustration got the better of me in my post. 🌞 For others who are trying to get Gatsby images to work in storybook, my teammate and I have found a solution:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
Describe the issue that you're seeing.
I am not able to render Images in storybook if they are using the
StaticImagecomponent fromgatsby-plugin-image.I see the following error in the Storybook console:
How can I get gatsby-plugin-image to work within a storybook Environment and/or is it possible to return some sort of default image if the sharp server is not available?
When using gatsby-plugin-image the images are processed via sharp, consequently I am unable to view these images through third-party programs such as Storybook because when storybook is running I don't have access to the sharp server used by gatsby-plugin-image.
Note: The image renders just fine when viewing the image via the Gatsby Development Server and/or when building the static site.
Steps to reproduce
Expected result
Actual result
Environment
System:
OS: Linux 5.8 Ubuntu 20.04.2 LTS (Focal Fossa)
CPU: (16) x64 AMD Ryzen 7 4800H with Radeon Graphics
Shell: 5.8 - /usr/bin/zsh
Binaries:
Node: 14.16.0 - ~/.nvm/versions/node/v14.16.0/bin/node
Yarn: 1.22.10 - ~/.nvm/versions/node/v14.16.0/bin/yarn
npm: 7.14.0 - ~/.nvm/versions/node/v14.16.0/bin/npm
Browsers:
Chrome: 91.0.4472.77
Firefox: 88.0.1
npmPackages:
gatsby: 3.6.2 => 3.6.2
gatsby-plugin-image: 1.6.0 => 1.6.0
gatsby-plugin-manifest: 3.6.0 => 3.6.0
gatsby-plugin-mdx: 2.6.0 => 2.6.0
gatsby-plugin-react-helmet: 4.6.0 => 4.6.0
gatsby-plugin-remove-generator: 1.1.0 => 1.1.0
gatsby-plugin-sharp: 3.6.0 => 3.6.0
gatsby-plugin-sitemap: 4.2.0 => 4.2.0
gatsby-plugin-styled-components: 4.6.0 => 4.6.0
gatsby-source-filesystem: 3.6.0 => 3.6.0
gatsby-transformer-remark: 4.3.0 => 4.3.0
gatsby-transformer-sharp: 3.6.0 => 3.6.0
Beta Was this translation helpful? Give feedback.
All reactions