Skip to content

Commit 51f38aa

Browse files
committed
Merge pull request #32957 from storybookjs/yann/handle-svgr-use-cases
Nextjs Vite: Update internal plugin to support `svgr` use cases (cherry picked from commit 7f51296)
1 parent 3950cc8 commit 51f38aa

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

code/frameworks/nextjs-vite/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
"@storybook/react": "workspace:*",
8484
"@storybook/react-vite": "workspace:*",
8585
"styled-jsx": "5.1.6",
86-
"vite-plugin-storybook-nextjs": "^3.0.0"
86+
"vite-plugin-storybook-nextjs": "^3.1.0"
8787
},
8888
"devDependencies": {
8989
"@types/node": "^22.0.0",

code/frameworks/nextjs-vite/src/preset.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,16 @@ export const viteFinal: StorybookConfigVite['viteFinal'] = async (config, option
6868
await normalizePostCssConfig(searchPath);
6969
}
7070

71-
const { nextConfigPath } = await options.presets.apply<FrameworkOptions>('frameworkOptions');
71+
const { nextConfigPath, image = {} } =
72+
await options.presets.apply<FrameworkOptions>('frameworkOptions');
7273

7374
const nextDir = nextConfigPath ? dirname(nextConfigPath) : undefined;
7475

76+
const vitePluginOptions = {
77+
image,
78+
dir: nextDir,
79+
};
80+
7581
return {
7682
...reactConfig,
7783
resolve: {
@@ -83,6 +89,6 @@ export const viteFinal: StorybookConfigVite['viteFinal'] = async (config, option
8389
'styled-jsx/style.js': fileURLToPath(import.meta.resolve('styled-jsx/style')),
8490
},
8591
},
86-
plugins: [...(reactConfig?.plugins ?? []), vitePluginStorybookNextjs({ dir: nextDir })],
92+
plugins: [...(reactConfig?.plugins ?? []), vitePluginStorybookNextjs(vitePluginOptions)],
8793
};
8894
};

code/frameworks/nextjs-vite/src/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ type BuilderName = CompatibleString<'@storybook/builder-vite'>;
1111
export type FrameworkOptions = {
1212
/** The path to the Next.js configuration file. */
1313
nextConfigPath?: string;
14+
image?: {
15+
includeFiles?: string[];
16+
excludeFiles?: string[];
17+
};
1418
builder?: BuilderOptions;
1519
};
1620

code/yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6553,7 +6553,7 @@ __metadata:
65536553
semver: "npm:^7.3.5"
65546554
styled-jsx: "npm:5.1.6"
65556555
typescript: "npm:^5.8.3"
6556-
vite-plugin-storybook-nextjs: "npm:^3.0.0"
6556+
vite-plugin-storybook-nextjs: "npm:^3.1.0"
65576557
peerDependencies:
65586558
next: ^14.1.0 || ^15.0.0 || ^16.0.0
65596559
react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
@@ -26391,9 +26391,9 @@ __metadata:
2639126391
languageName: node
2639226392
linkType: hard
2639326393

26394-
"vite-plugin-storybook-nextjs@npm:^3.0.0":
26395-
version: 3.0.0
26396-
resolution: "vite-plugin-storybook-nextjs@npm:3.0.0"
26394+
"vite-plugin-storybook-nextjs@npm:^3.1.0":
26395+
version: 3.1.0
26396+
resolution: "vite-plugin-storybook-nextjs@npm:3.1.0"
2639726397
dependencies:
2639826398
"@next/env": "npm:16.0.0"
2639926399
image-size: "npm:^2.0.0"
@@ -26405,7 +26405,7 @@ __metadata:
2640526405
next: ^14.1.0 || ^15.0.0 || ^16.0.0
2640626406
storybook: ^0.0.0-0 || ^9.0.0 || ^10.0.0 || ^10.0.0-0
2640726407
vite: ^5.0.0 || ^6.0.0 || ^7.0.0
26408-
checksum: 10c0/bb460ddab4d46a98bdd1525c7f18117a0a335a3500243534955532b5a209d3e63aad369a96a669618dd13b785cabe74560b4439ce063c953c51b9ab44abb7b10
26408+
checksum: 10c0/a3c87a91eca84bda3b96eb8d66afa654542ed1ee3dbd3ec1a43dace4b53611e552a44d7ba8436888e965dbc6f099ddfa9c4ab91f691a19357ddc2f2cc940f9c5
2640926409
languageName: node
2641026410
linkType: hard
2641126411

0 commit comments

Comments
 (0)