-
-
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
Add @storybook/nextjs
framework
#19382
Conversation
8703869
to
4df9964
Compare
Socket Security Report👍 No new dependency issues detected in pull request Socket.dev scan summary
Bot CommandsTo ignore an alert, reply with a comment starting with Powered by socket.dev |
|
||
- `nextConfigPath`: The absolute path to the `next.config.js` | ||
|
||
### Next.js's Image Component |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note: One problem I've been having with my addon was that it wasn't very clear that more advanced configuration options weren't supported because of their reliance on either the resolved nextjs config (not just the file but the tons of defaults that nextjs adds which changes between versions btw), or a running nextjs server to optimize the images.
See this discussion (and probably take it over too) to discuss with the nextjs team about exposing a function to load and add defaults to the resolved nextjs config so we can support more features of images vercel/next.js#40891
* // after main script path truncation | ||
* scopedResolve('styled-jsx') === '/some/path/node_modules/styled-jsx' | ||
*/ | ||
export const scopedResolve = (id: string): string => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If including this in the storybook code base, I'd recommend revisiting this function. This was a hack to get local development working where sample projects in the root repository's examples
folder could reference the addon easily and not have packages conflict. This might be unneeded for storybook's monorepo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible alternative:
storybook/code/lib/cli/src/dirs.ts
Lines 1 to 5 in d35ed61
import { dirname } from 'path'; | |
export function getBaseDir() { | |
return dirname(require.resolve('@storybook/cli/package.json')); | |
} |
question: what is the current position on supporting the vite builder? I've gotten a few issues on my addon's repo for vite support. |
Isn't Next Webpack-only? I don't understand why people would ask for that. I'm away from my computer at the moment; will look into those issues later for my own edification. Thanks for taking a look, Ryan! |
Yup. It is. It seems there is a hunger to use the vite builder just for storybook though. I imagine this is possible too. I don’t know how much of the code can be shared however :/ |
|
4df9964
to
062a92e
Compare
Co-authored-by: Yann Braga <[email protected]>
f887fa3
to
24f01bd
Compare
* https://webpack-3.cdn.bcebos.com/loaders/css-loader/#url | ||
* https://webpack-3.cdn.bcebos.com/loaders/css-loader/#import | ||
*/ | ||
const getImportAndUrlCssLoaderOptions = (nextConfig: NextConfig) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its worth checking if with the upgrade of storybook to v7 we can get rid of css loader v4 support.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Ryan, in Storybook 7 we only support Webpack5. Does that mean we can remove some of the code here? I'm a little lost in what actual chunks could be removed. Maybe you could help us navigate that? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe.... it wasn't that some people were using webpack 4. My addon never supported webpack 4. It was just that some people because of npm versiom resolution were using various css loader major versions. I believe part of the problem was from some storybook internal dependencies but I can't remember.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RyanClementsHax/storybook-addon-next#22 here is one of the related issues
- Remove `frameworkToRenderer` - This information is already available from `baseGenerator`'s arguments - Add `hasFrameworkTemplates` - Ensures frameworks with templates use those instead of templates for associated renderer - Follows pattern of `hasInteractiveStories` - Update `copyComponents` to copy common template files before (instead of after) framework/render template files - Allows framework/renderer template files to contain, e.g. `Introduction.stories.mdx` and have it not be overwritten
- Apply STORYBOOK_REPRO_GENERATOR to env when running `sb init` in repro generator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 🎉 🎉
It looks like there is no support for |
I'd recommend doing this and also going through the closed issues. Some of the issues opened were valid but were automatically closed because no activity was recorded on them for some time. |
@bertho-zero — It was decided to ship what we have ready (and what |
What I did
@storybook/nextjs
frameworkhasFrameworkTemplates
hasInteractiveStories
copyComponents
to copy common template files before (insteadof after) framework/render template files
Introduction.stories.mdx
and have it not be overwrittensb init
in repro generatorHow to test
yarn generate-repros-next --template nextjs/default-js --local-registry
yarn task --task sandbox --template nextjs/default-js --from-local-repro
nextjs/default-ts
If your answer is yes to any of these, please make sure to include it in your PR.