-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Vite: Automatically use vite.config.js #19026
Conversation
b521eed
to
aa4c76a
Compare
This is working correctly for react, and for svelte projects that do not use svelte-native stories. I cannot yet get svelte-native stories working in 7.0, I'm not sure if it's supported yet or not. Once that's working, we may need to remove That said, this PR is ready for review. |
It's expected that the original vite.config.js should have one, and we're using that now.
We just need it for processing mdx, it doesn't need to hmr anything.
I see that Historie has a way to easily filter out unwanted plugins by name (https://histoire.dev/guide/config.html#ignoring-plugins), maybe that's something we could explore too. Not sure where that would go in the config file though. Maybe |
# Conflicts: # code/lib/builder-vite/src/vite-config.ts
…-when-editing-a-csf-file
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.
LGTM
…ng-a-csf-file' into vite-autoconfig
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.
Without deep knowledge of all the decisions here, this LGTM
Issue:
What I did
This is an exploration into two things:
vite.config.js
(or similar) vite config file as the basis for the storybook vite builder, while still allowingviteFinal
as an override if necessary. This makes it much easier to get up-and-running with storybook in a vite project, and would also solve Babel configuration builder-vite#286, a particularly nasty issue, because we could just use the babel config that the user set in their normal vite config..stories.x
files from HMR, because it conflicted with Webpack's HMR. This approach removes those exclusions, and allows HMR to happen in stories files.Item 2) caused a bit of problems, because vite incorrectly adds HMR boundaries to story files that it shouldn't (vitejs/vite#9869). Until/unless that issue is fixed, the approach taken here is to add one more
post
plugin, which looks at only.stories
files, and removesimport.meta.hot.accept();
if it finds it, which allows the change to bubble up and be handled correctly.How to test
Run
yarn sandbox
, pick one of the vite frameworks, and answer the questions that it asks. You should then be able to go into/sandbox
and start up storybook. Try configuring vite withvite.config.js
, and verify that your changes appear in the vite config by logging it out inviteFinal
. Verify that modifying the config inviteFinal
still impacts the final build.