-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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 NextImage's broken #17950
Comments
Encountered same issue. It seems the fix through
and then creating an alias for
Note: The |
Thanks for the workaround @optimista, it worked a charm for us! |
Thank you @optimista! it worked by changing the following two points!
webpackFinal: async (config) => {
- config.resolve.alias["next/image"] = require.resolve("./.storybook/NextImage.js");
+ config.resolve.alias["next/image"] = require.resolve("./NextImage.js");
+ return config;
}, |
ビルドしたStoryBookをChromaticや `npx http-server storybook-static` で立ち上げると以下のようなエラーが出る。 ``` Uncaught TypeError: Cannot redefine property: default at Function.defineProperty (<anonymous>) at preview.jsx:6:8 ``` これはStoryBook6.4.22から壊れているとのことで、このIssueでワークアラウンドが紹介されており、それで解決できた。 storybookjs/storybook#17950
This didn't work for me at [email protected] If you're curious, the error I was getting was:
Using |
@bonesoul @iamgoddog I'm still @6.4, but this worked for me. |
Yes it worked @6.4 for me also. |
@iamgoddog I believe the |
Had this issue. Can confirm that this works in 6.5. Thanks! |
Anyone using version "^6.5" managed to solve it? |
It worked on v6.5 // .storybook/preview.js
import * as NextImage from 'next/image';
import React from 'react';
const OriginalNextImage = NextImage.default;
Object.defineProperty(NextImage, 'default', {
configurable: true,
value: (props) =>
React.createElement(OriginalNextImage, { ...props, unoptimized: true }),
});
Object.defineProperty(NextImage, '__esModule', {
configurable: true,
value: true,
}); |
Jeepers creepers!! I just released https://github.com/storybookjs/storybook/releases/tag/v7.0.0-alpha.57 containing PR #20028 that references this issue. Upgrade today to the
Closing this issue. Please re-open if you think there's still more to do. |
I've been using the trick here to fix optimized next.js image components:
https://storybook.js.org/blog/get-started-with-storybook-and-next-js/
though with latest builds, it seems to be broken. any fixes?
The text was updated successfully, but these errors were encountered: