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

Add a flag to download assets locally #42

Open
paulsheldrake opened this issue Sep 15, 2023 · 6 comments
Open

Add a flag to download assets locally #42

paulsheldrake opened this issue Sep 15, 2023 · 6 comments

Comments

@paulsheldrake
Copy link

Hello, this is a feature request. We're working on a project, and we'd like the storybook UI to generate a static version that can be shared without the Drupal site running.

I was wondering about the feasibility of getting a flag in the storybook config that would allow it to support that.

A couple of changes I think would need to be made:

  • Downloading all the CSS/JS assets locally.
    • Looking at this code here, where you process the response from the server
      const htmlDoc = parser.parseFromString(htmlContents, 'text/html');
      . Looks like it could be modified to process the response more to copy the assets files locally to storybook.
  • Fetching all the components in one go instead of on click.
    • No immediate ideas on how to approach this.

Ideally, we could then add a param to the storybook command that would be like. npm run storybook --server-static --out=.out and it would make the magic happen.

Looking forward to hearing your thoughts

@agarzola
Copy link

I haven't tried to do this yet with a Storybook install that works with server-rendered components, but Storybook supports generating a static webapp. Have you tried that?

@paulsheldrake
Copy link
Author

We have tried that as we use the static feature but the site ends up making a request to the URL listed in the server config. What I'm hoping for a is a way to work around that dependency

@agarzola
Copy link

Ah, interesting! I guess when Storybook is configured to use server-rendered components, it does not include the components in that static build. Which I suppose is a reasonable default, but I can see how it sort of defeats the purpose of generating a static build in the first place, depending on your expectation of what falls within the scope the “static build.”

This storybookjs/storybook comment describes what you are referring to, I think. I suggest voicing your interest in better support for server-side rendered components in that issue as well.

@danny-englander
Copy link

Just noting that there is a storybook build command that will compile all the components as a static site.

@agarzola
Copy link

agarzola commented Oct 4, 2023

It appears that command does not include proactively generating static files for server-rendered components.

@fogpuddle
Copy link

Any update on this? I am looking how to generate storybook files that can be publicly accessible while still using cl_server for development. I haven't tried adjusting CORS settings so Storybook can run on production with cl_server yet, but I would prefer a static storybook build without the dependency of Drupal as mentioned here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants