Skip to content

Instantly share code, notes, and snippets.

@ChronSyn
Forked from dannyhw/main.ts
Created August 28, 2025 22:07
Show Gist options
  • Save ChronSyn/52456417b826c0202a0474eac37fbf56 to your computer and use it in GitHub Desktop.
Save ChronSyn/52456417b826c0202a0474eac37fbf56 to your computer and use it in GitHub Desktop.
make EXPO_PUBLIC accessible to storybook
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