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] Storybook environment variables not fully supported in Vitest plugin #29779

Closed
Tracked by #29770 ...
vanessayuenn opened this issue Dec 2, 2024 · 0 comments · Fixed by #29792
Closed
Tracked by #29770 ...

[Bug] Storybook environment variables not fully supported in Vitest plugin #29779

vanessayuenn opened this issue Dec 2, 2024 · 0 comments · Fixed by #29792

Comments

@vanessayuenn
Copy link
Contributor

By default, Storybook only reads env variables prefixed with STORYBOOK_ (and VITE_ for Vite projects), and if you want it to read more variables, you have to specify it in main.js

// .storybook/main.js
export default {
  env: (config) => ({
    ...config,
    EXAMPLE_VAR: 'An environment variable configured in Storybook',
  }),
};

In Vitest with the Storybook plugin, on the other hand, it only takes VITE_ variables into consideration. Also, it will not know about that extra env passed from main.js.

💡 Solutions/Action items:

  • Make the plugin handle STORYBOOK_ variables by default
  • Make the plugin smarter and merge the env config from main.js with the env config from Vitest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants