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

CLI: Support community builders in sb init #14651

Merged
merged 1 commit into from
Apr 19, 2021
Merged

Conversation

shilman
Copy link
Member

@shilman shilman commented Apr 19, 2021

Issue: N/A

What I did

Now sb init --builder can take an arbitrary package such as storybook-builder-vite. It will add it to main.js and also install it as a dependency.

The "core" builders of webpack4 and webpack5 are also supported

How to test

npm init @vitejs/app # choose react
cd vite-project
/path/to/storybook/lib/cli/bin/index.js init --builder storybook-addon-vite

Copy link
Member

@yannbf yannbf left a comment

Choose a reason for hiding this comment

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

Overall it looks good, I'm just wondering what happens if you pass a wrong builder like --builder foo

@shilman
Copy link
Member Author

shilman commented Apr 19, 2021

@yannbf Then it tries to install a package called foo and fails 😉

@yannbf
Copy link
Member

yannbf commented Apr 19, 2021

@yannbf Then it tries to install a package called foo and fails 😉

Yea, I hope in that case nothing would happen (rollback with no files generated etc) and the user could just rerun the command with the correct name, although I don't think that's the case.
If the dependency does succeed to install (funny enough, foo is a package!), then it will be applied to mainjs even though it's not correct. I guess this is an edge case, something to improve later on.

@shilman shilman merged commit 59fab49 into next Apr 19, 2021
@shilman shilman deleted the cli-add-community-builders branch April 19, 2021 13:21
@vasileermicioi
Copy link

vasileermicioi commented Apr 20, 2021

npx [email protected] init --builder storybook-addon-vite gives an error npm ERR! 404 Not Found - GET https://registry.npmjs.org/storybook-addon-vite - Not found

@yannbf
Copy link
Member

yannbf commented Apr 20, 2021

Hey @vasileermicioi I believe the correct package name is storybook-builder-vite. Can you try that out?

@vasileermicioi
Copy link

yes, it works with npx [email protected] init --builder storybook-builder-vite

as a side note, good performance for yarn storybook, now takes 8-9 seconds on my PC versus 18-20 seconds before

@vasileermicioi
Copy link

with vite builder hmr is not working for stories :(

@yannbf
Copy link
Member

yannbf commented Apr 20, 2021

Thanks for your input! However, keep in mind that the vite builder is from the community and not oficial from storybook, so it's best to give feedback in the builder repository. The builder is very fresh, it's still in version 0.0.3 and will likely be polished as the time goes by.

There's an issue related to HMR in the repo already: storybookjs/builder-vite#3

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.

3 participants