Skip to content

How to prevent .storybook directory from being bundled #535

Answered by dannyhw
hayata-suenaga asked this question in Q&A
Discussion options

You must be logged in to vote

@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:

defaultConfig.resolver.resolveRequest = (context, moduleName, platform) => {
  const defaultResolveResult = context.resolveRequest(
    context,
    moduleName,
    platform
  );

  if (
    process.env.STORYBOOK_ENABLED !== "true" &&
    //                  put your storybook config folder here👇
    defaultResolveResult?.filePath?.includes?.(".storybook/")
  ) {
    return {
  …

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@hayata-suenaga
Comment options

@hayata-suenaga
Comment options

@dannyhw
Comment options

@dannyhw
Comment options

Answer selected by hayata-suenaga
@hayata-suenaga
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants