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

Vite: Fix static source handling for addon-docs #20147

Merged
merged 1 commit into from
Dec 8, 2022
Merged

Conversation

joshwooding
Copy link
Member

@joshwooding joshwooding commented Dec 8, 2022

Issue: #19882 #19554

What I did

  • Add csf-plugin

How to test

  • Is this testable with Jest or Chromatic screenshots?
  • Does this need a new example in the kitchen sink apps?
  • Does this need an update to the documentation?

If your answer is yes to any of these, please make sure to include it in your PR.

@@ -0,0 +1,15 @@
import type { Plugin } from 'vite';
Copy link
Member Author

Choose a reason for hiding this comment

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

Kept a plugin so vite-config stayed clean

Copy link
Member

@IanVS IanVS left a comment

Choose a reason for hiding this comment

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

This really simplifies things nicely! The only part I'm not sure about is getting the settings from addon-docs. @shilman is this something that @storybook/csf-plugin itself should be doing, maybe?

// @ts-expect-error - not sure what type to use here
addons.find((a) => [a, a.name].includes('@storybook/addon-docs'))?.options ?? {};

return vite(docsOptions?.csfPluginOptions);
Copy link
Member

Choose a reason for hiding this comment

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

It feels to me like @storybook/csf-plugin itself should take care of this...

Copy link
Member

Choose a reason for hiding this comment

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

I don't think csf-plugin should know about the user's main.js and it makes sense for addon-docs to glue things together like this. Hopefully this all goes away in 7.x with the annotations server & simplifies things even further.

@shilman shilman changed the title Add csf-plugin to vite Vite: Add csf-plugin handling for addon-docs Dec 8, 2022
@shilman shilman changed the title Vite: Add csf-plugin handling for addon-docs Vite: Fix static source handling for addon-docs Dec 8, 2022
Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

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

Looks great! 💯

// @ts-expect-error - not sure what type to use here
addons.find((a) => [a, a.name].includes('@storybook/addon-docs'))?.options ?? {};

return vite(docsOptions?.csfPluginOptions);
Copy link
Member

Choose a reason for hiding this comment

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

I don't think csf-plugin should know about the user's main.js and it makes sense for addon-docs to glue things together like this. Hopefully this all goes away in 7.x with the annotations server & simplifies things even further.

@shilman shilman merged commit 903c037 into next Dec 8, 2022
@shilman shilman deleted the add-csf-plugin-to-vite branch December 8, 2022 06:20
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