#Storybook config issue with route groups (NextJS 13)

7 messages · Page 1 of 1 (latest)

woven orbit
#

Hi guys, in my NextJS (v13.4.2) project I'm using some route groups (https://nextjs.org/docs/app/building-your-application/routing/route-groups) and I've the following folders/files structure:

/
├── .storybook
| ├── main.js
| └── preview.js
├── app
| ├── (components)
| | ├── button
| | | ├── button.jsx
| | | └── button.stories.js
| | └── ... other components
| └── ... other folders
└── ... other forlders/files

So, basically, inside each component's folder I also have the corresponding .stories.js file. Now, in my "main.js" config file I have:

const config = {
stories: [ "../app/(components)/**/*.stories.@(js|jsx|ts|tsx)",],
... other configs
}

The issue is the fact of having those round brackets in the file path, because when I run "npm run storybook" I get "WARN - No story files found for the specified pattern: app/(components)/**/*.stories.@(js|jsx|ts|tsx)", meanwhile if I rename the "(components)" folder to just "components" I get no warnings and I can see my component's stories.

Tbh, I've also tried to add some escaping characters in the config path - e.g. "../app/\(components\)/**/*.stories.js", but that sadly seems to not works.

Do you guys have any idea on how to fix this problem?

Route Groups can be used to partition your Next.js application into different sections.

floral grotto
woven orbit
#

Hi! I've just tried with the double backslashes, but sadly it doesn't works 😢

#

It seems like it's reading those backslashes in some other way

floral grotto
#

Oh, dang. ☹️

It's interesting that it put an extra forward slash inside the parenthesis (app/(components/)/**/....

One of the maintainers created this picomatch playground, https://codesandbox.io/s/ebjlxm?file=/src/App.js, so you can at least experiment with different techniques without having to rebuild your Storybook.

I'm guessing this is a limitation/bug of the picomatch library, though.

picomatch-playground by yannbf using picomatch, react, react-dom, react-scripts, ts-dedent