Stories are not sorted by their export (in production)
See original GitHub issueDescribe the bug In production, stories are not sorted according to their export instead, they are sorted alphabetically.
How they should be sorted (working correctly in dev):
How they are actually sorted (in production):
To Reproduce I’ve tried to create an example but I could not reproduce the bug. Here is a working example: https://github.com/inovex/elements
- Pull repo
- Run
yarn install
- Run
yarn start
- See that the sorting is correct
- Run
cd packages/storybook
- Run
yarn build
- Run
cd dist
- Serve built content (e.g.
serve .
) - See wrong sorting order
Everything related to the storybook can be found under packages/storybook
.
System
System:
OS: macOS 10.15.7
CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
Binaries:
Node: 14.16.1 - ~/.nvm/versions/node/v14.16.1/bin/node
Yarn: 1.22.10 - ~/.nvm/versions/node/v14.16.1/bin/yarn
npm: 6.14.12 - ~/.nvm/versions/node/v14.16.1/bin/npm
Browsers:
Chrome: 91.0.4472.114
Firefox: 89.0
Safari: 14.1.1
npmPackages: (added manually because of monorepo)
"@storybook/addon-actions": "^6.3.2",
"@storybook/addon-essentials": "^6.3.2",
"@storybook/addon-links": "^6.3.2",
"@storybook/addon-viewport": "^6.3.2",
"@storybook/builder-webpack5": "^6.3.2",
"@storybook/manager-webpack5": "^6.3.2",
"@storybook/theming": "^6.3.2",
"@storybook/web-components": "^6.3.2",
Additional context It seems to be related to this issue: https://github.com/storybookjs/storybook/issues/15305
I’ve tried to sort the stories manually within the preview.js
but it only sorted the entries in the sidebar but not the actual content on the canvas. Meaning, I would click on the story on the top of the sidebar, leading me to the rendered story at the bottom of the page in the canvas.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:14
- Comments:43 (21 by maintainers)
With the new version:
And the default config (
preview.js
):Stories in prod build are still not in their imported order (“Playground” should be first, instead we get alphabetical order)
@shilman can you reopen?
Since I’ve upgraded from an older version (using Webpack 4) to version
6.4.22
using (Webpack 5), I have this phenomena already on dev mode. The stories all seem to be sorted alphabetically by default now. But the Official docs saysBy default, stories are sorted in the order in which they were imported.
, which is not the case anymore.