Skip to content

Setup for Storybook in NX monorepo library #495

Answered by ddanielcruzz
ddanielcruzz asked this question in Q&A
Discussion options

You must be logged in to vote

Go it working!

This is how my files ended

// .storybook/main.js

const rootMain = require('../../../.storybook/main');
const path = require('path');
const fs = require('fs');

function getPackageDir(filepath) {
  let currDir = path.dirname(require.resolve(filepath));
  // eslint-disable-next-line no-constant-condition
  while (true) {
    if (fs.existsSync(path.join(currDir, 'package.json'))) {
      return currDir;
    }
    const { dir, root } = path.parse(currDir);
    if (dir === root) {
      throw new Error(
        `Could not find package.json in the parent directories starting from ${filepath}.`
      );
    }
    currDir = dir;
  }
}

rootMain.stories.push(
  ...['../src/lib/**/*…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@ddanielcruzz
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by ddanielcruzz
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