Skip to content

Commit 6ec50cf

Browse files
committed
Nextjs Vite: Update internal plugin to support svgr use cases
1 parent 9d1fc3e commit 6ec50cf

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.1"
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.1"
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
@@ -26439,9 +26439,9 @@ __metadata:
2643926439
languageName: node
2644026440
linkType: hard
2644126441

26442-
"vite-plugin-storybook-nextjs@npm:^3.0.1":
26443-
version: 3.0.1
26444-
resolution: "vite-plugin-storybook-nextjs@npm:3.0.1"
26442+
"vite-plugin-storybook-nextjs@npm:^3.1.0":
26443+
version: 3.1.0
26444+
resolution: "vite-plugin-storybook-nextjs@npm:3.1.0"
2644526445
dependencies:
2644626446
"@next/env": "npm:16.0.0"
2644726447
image-size: "npm:^2.0.0"
@@ -26453,7 +26453,7 @@ __metadata:
2645326453
next: ^14.1.0 || ^15.0.0 || ^16.0.0
2645426454
storybook: ^0.0.0-0 || ^9.0.0 || ^10.0.0 || ^10.0.0-0
2645526455
vite: ^5.0.0 || ^6.0.0 || ^7.0.0
26456-
checksum: 10c0/f3962c8bd403afdcf8d1b1f02f32388733008e9cae35f94e1fdb47a658a4cef622e11e4f86bb66ab99a484a8ce89b519bc432782e0f965a0fd82b223354e6ac0
26456+
checksum: 10c0/a3c87a91eca84bda3b96eb8d66afa654542ed1ee3dbd3ec1a43dace4b53611e552a44d7ba8436888e965dbc6f099ddfa9c4ab91f691a19357ddc2f2cc940f9c5
2645726457
languageName: node
2645826458
linkType: hard
2645926459

0 commit comments

Comments
 (0)