With vite, how do I set the mode to use? #28480
Unanswered
emilbonnek
asked this question in
Help
Replies: 1 comment 2 replies
-
// .storybook/main.ts
const config: StorybookConfig = {
// ...
async viteFinal(config) {
const { mergeConfig } = await import('vite');
return mergeConfig(config, {
mode: 'whatever-mode-you-want',
});
},
}; This works for me. Make sure you empty your browser's cache, so it doesnt reuse the non-functional files when you refresh the storybook page. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
Background
Vite has the idea of 'modes', i.e the
.env.XYZ
to load in on top of the base.env
.In Vite we can run
vite build --mode production-internal
and that will load in.env.production-internal
for example.Modes are distinct from
NODE_ENV
and they can be whatever custom values are needed, for example Vitest sets mode to'test'
or'benchmark'
.https://vitejs.dev/guide/env-and-mode
Question
I can't figure out how I set the Vite mode to use in Storybook, maybe it is always just uses
'development'
or'production'
depending on theNODE_ENV
?https://storybook.js.org/docs/configure/environment-variables
I had hoped there would just be a
--mode
cli parameter when executing Storybook via the cli (dev or build), similar to Vite itself and other tooling has it. vite-bundle-visualizer1 is also a cli executable that loads the Vite configuration and it has a similar thing.So is this possible at the moment? Or is it something the team is looking to add in the future?
Additional information
No response
Create a reproduction
No response
Beta Was this translation helpful? Give feedback.
All reactions