How to prevent .storybook
directory from being bundled
#535
-
I am preparing my Expo application for production build using EAS. In my application, I conditionally import Storybook code based on environment variables to switch between the real application and the Storybook application. // This code is part of `_layout.tsx`. The project uses Expo Router
let AppEntry = EntryLayout;
if (Constants?.expoConfig?.extra?.STORYBOOK_ENABLED) {
AppEntry = require("@/.storybook").default;
}
export default AppEntry; Even when I want Metro to completely ignore files in the I have two questions:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 9 replies
-
Updating this to say that it is possible by returning empty modules, this was integrated into the withStorybook metro helper in the onDisabledRemoveStorybook option
|
Beta Was this translation helpful? Give feedback.
@hayata-suenaga just re-read the thread and I think I know what you need.
You probably don't need to use an index.js entry point or change your setup. You can use a new method I've been trying out where you just mock the modules in the storybook folder using a custom resolver in your metro config.
In metro config: