storybook icon indicating copy to clipboard operation
storybook copied to clipboard

Can't build directly into `static` dir

Open hacknug opened this issue 4 years ago • 1 comments

Version

@nuxtjs/storybook: v4.0.4 nuxt: v2.15.7

Reproduction Link

https://codesandbox.io/s/confident-leavitt-65nxb

Steps to reproduce

I've added a couple scripts to illustrate my issue.

  • storybook:build-works shows how you can build Storybook using the defaults and there's no issues.
  • storybook:build-breaks shows how if you try to build Storybook into the /static dir, the module will recursively copy the contents of the folder inside itself until the OS prevents from creating things in that dir.

What is Expected?

I would expect the module to remove the previous build dir (it already does this). Then if the user has specified a custom --output-dir, the module should check if that path is inside --static-dir.

If it is not inside --static-dir, I think everything works fine. If it is inside, the module should copy the contents of the static folder except for the folder that will be our --output-dir.

What is actually happening?

Because I'm trying to deploy my Storybook with my website, when the module copies my static files to the Storybook build dir, it also copies Storybook's dir. This causes said dir to be infinitely nested/duplicated.

I think this is causing my CodeSandbox example to not demo the issue properly. Try running it locally if it's still not clear what's going on. Find attached a screenshot showing how my static dir looks like after a build.

screenshot Captura de pantalla 2021-06-30 a las 17 27 02

hacknug avatar Jun 30 '21 15:06 hacknug

For anyone trying to deploy their storybook dir with their website, this script allows you to workaround the described issue:

rm -r -f static/storybook && nuxt storybook build && mv storybook-static static/storybook

hacknug avatar Jul 19 '21 09:07 hacknug

v4 of this module is no longer actively supported. Please try the newest version and open an new issue if the problem persists. Thank you for your understanding.

tobiasdiez avatar May 01 '24 07:05 tobiasdiez