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 7 replies
-
Metro doesn't really have a good way to do this, one thing you can do is change how you run storybook conditionally. You can instead try this approach with sourceExts that changes which file gets loaded via a metro config changes instead of conditional app code |
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: