Skip to content

Commit 8cdab6c

Browse files
fix: Always add Storybook last (#547)
* fix: always handle storybook as the last addon * Add changesets * Update packages/cli/lib/install.ts * fix lint * fix changeset --------- Co-authored-by: Manuel <[email protected]> Co-authored-by: Manuel Serret <[email protected]>
1 parent 01524b6 commit 8cdab6c

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

.changeset/slimy-rivers-think.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'sv': patch
3+
---
4+
5+
fix: always add `storybook` after all other add-ons

packages/cli/lib/install.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,12 @@ async function runAddon({ addon, multiple, workspace }: RunAddon) {
182182

183183
// orders addons by putting addons that don't require any other addon in the front.
184184
// This is a drastic simplification, as this could still cause some inconvenient cituations,
185-
// but works for now in contrary to the previouse implementation
185+
// but works for now in contrary to the previous implementation
186186
function orderAddons(addons: Array<Addon<any>>, setupResults: Record<string, AddonSetupResult>) {
187-
return addons.sort(
188-
(a, b) => setupResults[a.id]?.dependsOn?.length - setupResults[b.id]?.dependsOn?.length
189-
);
187+
return addons.sort((a, b) => {
188+
// Adding storybook last means it will correctly detect and integrate with other addons like vitest and eslint
189+
if (a.id === 'storybook') return 1;
190+
if (b.id === 'storybook') return -1;
191+
return setupResults[a.id]?.dependsOn?.length - setupResults[b.id]?.dependsOn?.length;
192+
});
190193
}

0 commit comments

Comments
 (0)