chromaui / chromatic-cli

Chromatic CLI: `npx chromatic`
https://www.chromatic.com/docs/cli
MIT License
289 stars 70 forks source link

Storybook 8 + Vite + Turbosnap => Failed to retrieve dependent story files #28973 #1027

Closed julianCast closed 2 months ago

julianCast commented 2 months ago

Describe the bug

Having the following: Storybook: 8.2.5 React-Vite: 8.2.5 Turbosnap enabled (onlyChanged)

If I set onlyChanged: false everything works fine. I don't have any vite.config.ts file.

Structure

image

Main.ts

const config: StorybookConfig = {
  stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
  addons: [
    getAbsolutePath("@storybook/addon-a11y"),
    getAbsolutePath("@storybook/addon-links"),
    getAbsolutePath("@storybook/addon-essentials"),
    getAbsolutePath("@storybook/addon-interactions"),
  ],
  framework: {
    name: getAbsolutePath("@storybook/react-vite"),
    options: {},
  },
  async viteFinal(config, { configType }) {
    const { mergeConfig } = await import("vite");

    if (configType === "DEVELOPMENT") {
      // Your development configuration goes here
    }
    if (configType === "PRODUCTION") {
      // Your production configuration goes here.
    }
    return mergeConfig(config, {
      // Your environment configuration here
    });
  },
  typescript: {
    check: true,
    reactDocgen: "react-docgen-typescript",
    reactDocgenTypescriptOptions: {
      shouldExtractLiteralValuesFromEnum: true,
      propFilter: (prop) => (prop.parent ? !/node_modules/.test(prop.parent.fileName) : true),
    },
  },
  docs: {
    autodocs: true,
  },

Action.yml

image

I get the following error:

image

Reproduction link

Not provided

Reproduction steps

No response

System

Storybook Environment Info:

  System:
    OS: macOS 14.4.1
    CPU: (8) arm64 Apple M1 Pro
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.12.2 - ~/.nvm/versions/node/v20.12.2/bin/node
    Yarn: 3.8.3 - ~/.nvm/versions/node/v20.12.2/bin/yarn <----- active
    npm: 10.5.0 - ~/.nvm/versions/node/v20.12.2/bin/npm
  Browsers:
    Chrome: 127.0.6533.122
    Edge: 128.0.2739.42
    Safari: 17.4.1
  npmPackages:
    @storybook/addon-a11y: ^8.2.5 => 8.2.5
    @storybook/addon-docs: ^8.2.5 => 8.2.5
    @storybook/addon-essentials: ^8.2.5 => 8.2.5
    @storybook/addon-interactions: ^8.2.5 => 8.2.5
    @storybook/addon-links: ^8.2.5 => 8.2.5
    @storybook/react: ^8.2.5 => 8.2.5
    @storybook/react-vite: ^8.2.5 => 8.2.5
    @storybook/test: ^8.2.5 => 8.2.5
    @storybook/test-runner: ^0.19.1 => 0.19.1
    eslint-plugin-storybook: ^0.8.0 => 0.8.0
    storybook: ^8.2.5 => 8.2.5

Additional context

Wasn't happening in Storybook 7

cgbl-90 commented 2 months ago

@julianCast

We made an update as of CLI v.11.3.1 to check storybookBaseDir against your repository root as opposed to the cwd when using TurboSnap.

As of CLI v.11.3.2, we are using the cwd relative to the repo root as the default value for storybookBaseDir; if your project is in a subdirectory and you use workingDir to change your cwd, you shouldn't need to include storybookBaseDir unless it deviates from the cwd.

Can you set the storybookBaseDir option?

julianCast commented 2 months ago

We made an update as of CLI v.11.3.1 to check storybookBaseDir against your repository root as opposed to the cwd when using TurboSnap.

As of CLI v.11.3.2, we are using the cwd relative to the repo root as the default value for storybookBaseDir; if your project is in a subdirectory and you use workingDir to change your cwd, you shouldn't need to include storybookBaseDir unless it deviates from the cwd.

Can you set the storybookBaseDir option?

Well, that worked THANK YOU! Now my question, just for me to understand. What I have done is to remove the storybookBaseDir option.

But since this the structure of my repo:

packages/pk1/package.json - scripts from where we call storybook.
packages/pk1/src/storybook/.storybook
packages/pk1/storybook-static

Shouldn't I have to set storybookBaseDir: "./src/storybook" since my cwd is set as workingDir: "./packages/pk1", or it will recursively look for the storybook folder?

Oh I think is because my main package.json has this script command: "build-storybook": "yarn storybook build -c ./src/storybook/.storybook" so it links the proper storybook folder

julianCast commented 2 months ago

Close as it works now, thank you @cgbl-90 . Related issue https://github.com/chromaui/chromatic-cli/issues/971#issuecomment-2099410052

cgbl-90 commented 2 months ago

hey @julianCast regarding your other question, you can send us an email at support@chromatic.com and we will take a closer look