elderfo / react-native-storybook-loader

An automatic story loader for react-native-storybooks
https://github.com/elderfo/react-native-storybook-loader
MIT License
299 stars 27 forks source link

Load stories from parent folder #64

Open iamchathu opened 5 years ago

iamchathu commented 5 years ago

I'm developing a React Native UI Libary and I wanted to add storybook to the project.

So I created a react-native project inside the libary as .storybook-native folder structure looks like folowing

+--.storybook |--++--package.json |--++--... +--src |--++--Components |--++--|--++--Grid |--++--|--++--|--++--Grid.story.js

I have my config as

"config": {
    "react-native-storybook-loader": {
      "searchDir": [
        "../src"
      ],
      "pattern": "**/*.story.js",
      "outputFile": "./storybook/storyLoader.js"
    }
  },

But I get

bundling failed: Error: Unable to resolve module `../../src/Components/Grid/KTGrid.story` from `/Users/Chathu/Workspace/ui-rn/.storybook-native/storybook/storyLoader.js`: The module `../../src/Components/Grid/KTGrid.story` could not be found from `/Users/Chathu/Workspace/ui-rn/.storybook-native/storybook/storyLoader.js`. Indeed, none of these files exist:
  * `/Users/Chathu/Workspace/ui-rn/src/Components/Grid/KTGrid.story(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)`
  * `/Users/Chathu/Workspace/ui-rn/src/Components/Grid/KTGrid.story/index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)`
jeremybviseo commented 4 years ago

Hi, I've not experienced the same error, but i agree the fact react-native-storybook-loader is not able to search in a parent folder of package.json.

In my case, this is problematic for a project using yarn workspaces.

virgil9306 commented 3 years ago

For anyone coming from search engines, one possible solution is to just keep *.stories.{js/ts/x} inside the ./storybook folder.

But no responses for over 1 year, I think this project is dead. Making your own list of UI components will not be so difficult -- it won't take much more time than getting this library to work if your use case is quite unique.

elderfo commented 3 years ago

@virgil9306 feel free to submit a PR to address this issue.

virgil9306 commented 3 years ago

@virgil9306 feel free to submit a PR to address this issue.

If I can make time I certainly will try. Thanks for the plug-in by the way!