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

(suggestion) make the loader search multiple directories #14

Closed xareelee closed 7 years ago

xareelee commented 7 years ago

I'm starting to migrate my code to monorepo with multiple packages using lerna. Now I have two directories for snapshots: ./src and ./packages. I need react-native-storybook-loader to search multiple directories to support this monorepo.

From this (in package.json):

{
  "config": {
    "react-native-storybook-loader": {
      "searchDir": "./src",
    }
  }
}

to this:

{
  "config": {
    "react-native-storybook-loader": {
      "searchDir": ["./src", "./packages"],
    }
  }
}

Would you help improve this?

xareelee commented 7 years ago

Or use a new prop matches to set up the loader for different use cases if necessary.

{
  "config": {
    "react-native-storybook-loader": {
      "matches":  [
        {
          "searchDir": "./src",
          "pattern": "**/*.stories.js",
          "outputFile": "./storybook/storyLoaderForSrc.js"
        },
        {
          "searchDir": "./packages",
          "pattern": "**/ui/*.stories.js",
          "outputFile": "./storybook/storyLoaderForPackages.js"
        }
      ]
    }
  }
}
xareelee commented 7 years ago

Or make the cli tool scriptable:

node ./node_modules/.bin/rnstl --searchDir "./src" --pattern "**/*.stories.js" --outputFile "./storybook/storyLoader.js"

and then use npm/yarn scripts to setup multiple loaders.

elderfo commented 7 years ago

Thanks @xareelee, I really like all three ideas. I think it makes sense to start with adding support for arrays as a setting for searchDir. I can probably get that done over my lunch out and push it out for you.

After that, I think I may move on to the cli options (#15) and lastly matches (#16).

xareelee commented 7 years ago

@elderfo Great! Very appreciated!

BTW, I think storybook and storyshots should include your library to load .stories automatically for development and testing.