Created
August 21, 2025 15:33
-
-
Save dannyhw/544f1801673de515f2570fb196b70843 to your computer and use it in GitHub Desktop.
make EXPO_PUBLIC accessible to storybook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { StorybookConfig } from "@storybook/react-native-web-vite"; | |
import { InlineConfig, mergeConfig } from "vite"; | |
const main: StorybookConfig = { | |
stories: ["../components/**/*.stories.@(js|jsx|ts|tsx)"], | |
addons: ["@storybook/addon-docs", "@chromatic-com/storybook"], | |
framework: { | |
name: "@storybook/react-native-web-vite", | |
options: {}, | |
}, | |
viteFinal: (config) => { | |
return mergeConfig(config, { | |
define: Object.entries(process.env).reduce((acc, [key, value]) => { | |
if (key.startsWith("EXPO_PUBLIC_")) { | |
acc[`process.env.${key}`] = JSON.stringify(value); | |
} | |
return acc; | |
}, {} as Record<string, string>), | |
} satisfies InlineConfig); | |
}, | |
// env: , | |
}; | |
export default main; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This will take EXPO_PUBLIC_ env variables and include them in the vite environment as process.env.EXPO_PUBLIC_[name-of-env]