-
Notifications
You must be signed in to change notification settings - Fork 125
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
Allow rollupOptions
set by other plugins to be respected
#488
Conversation
rollupOptions
set by other plugins to be respected
Storybook (builder-vite) adds an `iframe.html` entry into the `rollupOptions` when building a static build. I found that `vite-plugin-ruby` is overriding these options meaning that the Storybook build fails. Here I am allowing any existing rollup options + inputs to be spread into the config before the plugin returns it.
Woah! Well done figuring this one out. I've been struggling with the storybook static builds for years on my vite-ruby projects and could not understand what was going on! |
@ElMassimo any chance you could have a look? I appreciate all your hard work and know that you have a lot on your plate with your suite of OSS projects so don't mean to rush you/come across as ungrateful. This would be awesome for all of us |
Also just run into this issue and couldn't understand why the iframe was missing until I came across this discussion. Is there a way to patch this manually until a proper fix is in place? I tried using the patched Gem:
But the iframe is still missing from builds... Thanks |
@ElMassimo I've seen that this is merged now, but still not getting the iframe in the Storybook output after updating to the latest version of this gem... do I need to update something else as well? |
Same @iamdriz, maybe it makes most sense to continue the conversation here. We might have had a different issue than @blake-simpson that's not vite_ruby related. |
@eriknygren Yeah I'm seeing the same issue as mentioned in the other conversation with the |
@iamdriz seeing the same. @blake-simpson have you got this working on your end now? |
Hi all, sorry for the late reply, I was away on a longer vacation. First of all thank you @ElMassimo for merging + releasing this! To the thread above, I also have the same issue. I can't quite pin down why but it seems all of the rollup options for storybook build --force-build-preview --preview-url=vite/iframe.html && \
cp -R storybook-static/sb-preview storybook-static/vite && \
cp -R storybook-static/sb-common-assets storybook-static/vite && \
cp -R storybook-static/sb-addons storybook-static/vite && \
cp storybook-static/index.json storybook-static/vite/index.json It's ugly but the best I can figure out for now. I'd be happy to hear if someone has a better way or if @ElMassimo knows a way to make the files build into This is however working for me locally but I'm having issues with GitHub pages. If anyone has anymore input please let me know. cc/ @eriknygren @iamdriz |
Thanks @blake-simpson for getting back to us. So I don't really understand the nuances of this, my And even when I copy files over manually, loading a page from the static build results in no components, it doesn't even look like it's trying to fetch them. I feel pretty stuck on this and don't know what to suggest. Maybe another approach is needed, maintaining a completely separate vite config for storybook for example. Would love to hear if anyone does find a solution, but personally I've sort of given up at the moment (althought I would love to have this working). |
Have you tried configuring Maybe you could pass the |
@ElMassimo Thank you that helps with the Interestingly though for me, in this case, the |
I'm returning with some good news, just got this working for me! 🎉 Running the storybook build command with these output dir vars have made sure everything ends up where expected. So in my "build-storybook": "VITE_RUBY_PUBLIC_OUTPUT_DIR='.' VITE_RUBY_PUBLIC_DIR='./storybook-static' storybook build" In my storybook config ( import path from 'path';
const config = {
...
staticDirs: ['../public'],
async viteFinal(storybookConfig) {
const { mergeConfig, loadConfigFromFile } = await import('vite');
const { config: mainAppConfig } = await loadConfigFromFile(
path.resolve(__dirname, '../vite.config.ts'),
);
const pickedConfigFieldsFromMainApp = { resolve: mainAppConfig.resolve };
const mergedConfig = mergeConfig(storybookConfig, pickedConfigFieldsFromMainApp);
return mergedConfig;
},
...
};
export default config; Without needing to copy anything over, Hopefully this unblocks everyone else too! cc @blake-simpson @iamdriz Edit: On a second review: I think the |
Description 📖
Storybook (builder-vite) adds an
iframe.html
entry into therollupOptions
when building a static build. I found thatvite-plugin-ruby
is overriding these options meaning that the Storybook build fails.Background 📜
Storybook builds are failing for projects using
vite-plugin-ruby
orvite-plugin-rails
.Build/Rollup options without the spread:
The Fix 🔨
Here I am allowing any existing rollup options + inputs to be spread into the config before the plugin returns it.
Rollup options with the spread:
Notes
I appreciate this may not be the correct fix for the problem. If you would like a different style / approach to solve this please let me know!