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

[Bug]: viteConfigPath has wrong types. #26921

Open
codingedgar opened this issue Apr 23, 2024 · 0 comments
Open

[Bug]: viteConfigPath has wrong types. #26921

codingedgar opened this issue Apr 23, 2024 · 0 comments

Comments

@codingedgar
Copy link

Describe the bug

viteConfigPath is in the wrong place according to types.

To Reproduce

https://stackblitz.com/edit/github-sgzxbx?file=.storybook%2Fmain.ts

System

Storybook Environment Info:

  System:
    OS: macOS 14.4.1
    CPU: (8) x64 Intel(R) Core(TM) i5-8279U CPU @ 2.40GHz
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.17.0 - ~/.nvm/versions/node/v18.17.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v18.17.0/bin/yarn <----- active
    npm: 9.6.7 - ~/.nvm/versions/node/v18.17.0/bin/npm
    pnpm: 8.9.2 - /usr/local/bin/pnpm
  Browsers:
    Chrome: 124.0.6367.62
    Edge: 124.0.2478.51
    Safari: 17.4.1
  npmPackages:
    @storybook/addon-actions: 8.0.9 => 8.0.9 
    @storybook/addon-essentials: 8.0.9 => 8.0.9 
    @storybook/addon-interactions: 8.0.9 => 8.0.9 
    @storybook/addon-links: 8.0.9 => 8.0.9 
    @storybook/react: 8.0.9 => 8.0.9 
    @storybook/react-vite: 8.0.9 => 8.0.9 
    @storybook/test: ^8.0.9 => 8.0.9 
    eslint-plugin-storybook: 0.8.0 => 0.8.0 
    msw-storybook-addon: 2.0.0 => 2.0.0 
    storybook: 8.0.9 => 8.0.9 
    storybook-dark-mode: 4.0.1 => 4.0.1

Additional context

import type { StorybookConfig } from '@storybook/react-vite';

const config: StorybookConfig = {
  ...
  framework: {
    name: '@storybook/react-vite',
    options: {
      viteConfigPath: '../configs/vite.storybook.config.ts', // <- Correct type
    },
  },
};

According to https://storybook.js.org/docs/builders/vite#override-the-default-configuration, this is right

export default {
  stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
  core: {
    builder: {
      name: '@storybook/builder-vite',
      options: {
        viteConfigPath: '../customVite.config.js',
      },
    },
  },
};

viteConfigPath: '../customVite.config.js',

however, the types suggest:

framework: {
    name: '@storybook/react-vite',
    options: {
      builder: {
        viteConfigPath: '../configs/vite.storybook.config.ts', // <- which is incorrect
      }
    },
  },

Realted links:

### Customize Vite config
The builder _will_ read your `vite.config.js` file, though it may change some of the options in order to work correctly.
It looks for the Vite config in the CWD. If your config is located elsewhere, specify the path using the `viteConfigPath` builder option:
```javascript
// .storybook/main.mjs
const config = {
framework: {
name: '@storybook/react-vite', // Your framework name here.
options: {
builder: {
viteConfigPath: '.storybook/customViteConfig.js',
},
},
},
};
export default config;
```

export type BuilderOptions = {
/**
* Path to vite.config file, relative to CWD.
*/
viteConfigPath?: string;
};

export type FrameworkOptions = {
builder?: BuilderOptions;
strictMode?: boolean;
/**
* Use React's legacy root API to mount components
* @description
* React has introduced a new root API with React 18.x to enable a whole set of new features (e.g. concurrent features)
* If this flag is true, the legacy Root API is used to mount components to make it easier to migrate step by step to React 18.
* @default false
*/
legacyRootApi?: boolean;
};
type StorybookConfigFramework = {
framework:
| FrameworkName
| {
name: FrameworkName;
options: FrameworkOptions;
};

@codingedgar codingedgar changed the title [Bug]: [Bug]: viteConfigPath has wrong types. Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant