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: Set default base for subfolder deployments #19383

Merged
merged 3 commits into from
Oct 31, 2022
Merged

Conversation

IanVS
Copy link
Member

@IanVS IanVS commented Oct 7, 2022

Issue: storybookjs/builder-vite#238

What I did

This sets the default base vite config to "./" instead of the default "/". This allows storybook to be deployed in a subfolder, rather than forcing it to be at the root. I was reluctant to make the change in 6.5, in case it's breaking, but I don't think it really should be.

@yannbf yannbf self-assigned this Oct 10, 2022
@yannbf
Copy link
Member

yannbf commented Oct 11, 2022

Hey @IanVS while trying to test this locally, I found an issue.

How to reproduce:

  1. Create a vite sandbox
  2. Run yarn build-storybook
  3. Run npx http-server .
  4. Check the /storybook-static path in the provided URL

Storybook should be served correctly, however no stories render in the preview.
In the terminal (and dev tools) you will get something like:

[2022-10-11T07:05:41.573Z]  "GET /assets/iframe.e543f527.js" Error (404): "Not found" 

If you serve the folder with npx http-server storybook-static instead, this work as expected.

@IanVS
Copy link
Member Author

IanVS commented Oct 11, 2022

Interesting, I'm honestly a bit surprised that npx http-server . ever works. Why would you want to serve the project root, rather than the built storybook files?

@yannbf
Copy link
Member

yannbf commented Oct 11, 2022

Interesting, I'm honestly a bit surprised that npx http-server . ever works. Why would you want to serve the project root, rather than the built storybook files?

so that I have a server running and I'm able to access storybook as a subpath e.g.

http://my-app/storybook-static/

How do you quickly test a storybook-in-a-subfolder scenario?

@IanVS
Copy link
Member Author

IanVS commented Oct 11, 2022

How do you quickly test a storybook-in-a-subfolder scenario?

There's a set of steps in the referenced issue, though I honestly haven't tried them:

npx build-storybook  --output-dir build/docs
npx serve@latest build

Browse to http://localhost:3000/docs/

@IanVS
Copy link
Member Author

IanVS commented Oct 18, 2022

@yannbf what's your current thinking on this change?

@IanVS
Copy link
Member Author

IanVS commented Oct 31, 2022

Hi @yannbf, just another friendly ping. I've had a few more support issues come through recently that this PR would solve.

@IanVS IanVS requested a review from yannbf October 31, 2022 02:53
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.

Thanks for the ping! I did some extra testing and it works perfectly. Sorry for the delay!

@yannbf yannbf merged commit e568418 into next Oct 31, 2022
@yannbf yannbf deleted the vite/base-config branch October 31, 2022 17:19
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