CLI: Detect vite project, use vite builder automatically #17860
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue:
What I did
This is intended to aid discoverability of the vite builder by automatically initializing a project with the vite builder if a vite config file is detected. It uses a similar approach of looking for a vite config file as vitest.
I could see also detecting whether to use the webpack5 builder, but I didn't do that here, it will fall back to webpack4, as before.
If a
--builder
option is explicitly provided, it will be used and autodetection won't run.This also cleans up a few other things, which I can remove if desired:
Not using community vite builder, skipping
afterinit
, since the distinction between the community vite builder and official vite builder is subtle and might be confusing to users setting up a new storybook project.Adding Storybook support to your "React" app
, since otherwise npm overwrote them once it started installs.The logs now look something like this:
How to test
Without some vite examples for e2e tests, I'm not sure how to write automated tests for this. I did test it out locally, though, and it worked great.