Skip to content

[Bug]: "../public" is always copied in the static build root even if I set it to go elsewhere #24627

@speyou

Description

@speyou

Describe the bug

I can put anything I like into the staticDirs config option, "../public" will always be copied at the root of the storybook-static folder during the last phase of the build.
My problem is: "../public" contains data unrelated to Storybook (for instance pdf document to download in the app) and, more importantly, "../public" contains an index.json file that will override the storybook generated index.json, breaking the build in the process (because without the index, stories are not found).

If it's working as intended, could someone point out how I can go over that and NOT copy index.json into "/storybook-static"?

To Reproduce

  1. Create a new app with storybook (for instance npm create vite@latest then npx storybook@latest init)
  2. Create a file public/index.json and put an empty JSON inside {}
  3. Set the staticDirs to anything other than ../public, for instance staticDirs: [ { from: "../public", to: "/foo" } ],
  4. Run the storybook build npm run build-storybook
  5. storybook-static/index.json doesn't contain the necessary data (should be something like { v:4, entries: {...) but instead is set at whatever you put in the public/index.json file (in this example, it's {})
  6. storybook-static/foo contains a copy of whatever was in the ../public folder (so the staticDirs property works BUT the copy is done twice, once at the root, once at the directory I asked it to use)

System

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions