简体   繁体   English

Storybook - 查找 all.stories 文件,无论位置如何

[英]Storybook - Find all .stories files regardless of location

I'm using storybook and I have stories in various locations across my application.我正在使用故事书,我在应用程序的不同位置都有故事。 Is it possible to pull them all into storybook, without having to specify the pattern for each in the stories array in main.js.是否可以将它们全部拉入故事书中,而不必在 main.js 的故事数组中为每个指定模式。

Currently I'm doing this to find them, but I'd rather not have to specify each path if possible.目前我这样做是为了找到它们,但如果可能的话,我宁愿不必指定每条路径。 Is there a pattern to find every story from the root down?是否有一种模式可以从头到尾找到每个故事?

module.exports = {
  stories: [
    '../stories/**/*.stories.@(js|jsx|ts|tsx)',
    '../libs/**/src/lib/*/*.stories.@(js|jsx|ts|tsx)',
    '../stories/**/**/*.stories.@(js|jsx|ts|tsx)',
  ],
};

This one should do, given your patterns in the question above.鉴于您在上述问题中的模式,这一个应该做。 With this code, you can place the files in any subfolder of the parent folder.使用此代码,您可以将文件放在父文件夹的任何子文件夹中。 ** means any number of intermediary folders in the path. **表示路径中任意数量的中间文件夹。

module.exports = {
  stories: [
    '../**/*.stories.@(js|jsx|ts|tsx)',
  ],
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM