Image experimental layout="raw" support
See original GitHub issueDescribe the bug
I’m using the experimental “raw” layout but with storybook I get the following error:
The “raw” layout is currently experimental and may be subject to breaking changes. To use layout=“raw”, include
experimental: { images: { layoutRaw: true } }in your next.config.js file.

I do have allowed this experimental feature in next.config.js, and also configured storybook main.js to use the next.config.js file (“nextConfigPath”). However it doesn’t seem to work.
Are experimental features not supported, or is there anything I could do to make this work?
Your minimal, reproducible example
not yet…
Steps to reproduce
Create a storybook with an Image component with props layout="raw".
Expected behavior
If the experimental images: { layoutRaw: true, } is available in next.config.js, the Image component should load.
How often does this bug happen?
No response
Screenshots or Videos
No response
Platform
Ubuntu 20.04 (WSL2) Next.js 12.1.4 Storybook 6.4.19 storybook-addon-next 1.6.2
storybook-addon-next version
1.6.2
Additional context
No response
Issue Analytics
- State:
- Created a year ago
- Comments:13 (5 by maintainers)

Top Related StackOverflow Question
After looking into this further, I have a working solution on the image-config branch.
The problem I’m working through now is how I’m going to deal with how the addon already unoptimizes images (that was the poor man’s way of getting next/image working in storybook). Injecting image config seems to be a more robust and “correct” way of dealing with images.
It seems to me like I should remove the automatic unoptimization and publish this as v2.
I’ll have to do more research into this, but because of these new findings, this is actually intended behavior so I’ll remove the bug label.
FWIF, I was able to get the workaround working with 12.1.5.
I first needed to use the
npx sb@next upgrade --prereleasecommand to upgrade my Storybook from webpack 4 to webpack 5. Then I was able to add the following to my.storybook.main.jsfileWe already had the correct code in the
preview.jslike they describe in the link so I didn’t need to update that.