Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/frameworks/nextjs-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"@storybook/react": "workspace:*",
"@storybook/react-vite": "workspace:*",
"styled-jsx": "5.1.6",
"vite-plugin-storybook-nextjs": "^3.0.1"
"vite-plugin-storybook-nextjs": "^3.1.0"
},
"devDependencies": {
"@types/node": "^22.0.0",
Expand Down
10 changes: 8 additions & 2 deletions code/frameworks/nextjs-vite/src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,16 @@ export const viteFinal: StorybookConfigVite['viteFinal'] = async (config, option
await normalizePostCssConfig(searchPath);
}

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

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

const vitePluginOptions = {
image,
dir: nextDir,
};

return {
...reactConfig,
resolve: {
Expand All @@ -83,6 +89,6 @@ export const viteFinal: StorybookConfigVite['viteFinal'] = async (config, option
'styled-jsx/style.js': fileURLToPath(import.meta.resolve('styled-jsx/style')),
},
},
plugins: [...(reactConfig?.plugins ?? []), vitePluginStorybookNextjs({ dir: nextDir })],
plugins: [...(reactConfig?.plugins ?? []), vitePluginStorybookNextjs(vitePluginOptions)],
};
};
4 changes: 4 additions & 0 deletions code/frameworks/nextjs-vite/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ type BuilderName = CompatibleString<'@storybook/builder-vite'>;
export type FrameworkOptions = {
/** The path to the Next.js configuration file. */
nextConfigPath?: string;
image?: {
includeFiles?: string[];
excludeFiles?: string[];
};
builder?: BuilderOptions;
};

Expand Down
10 changes: 5 additions & 5 deletions code/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6553,7 +6553,7 @@ __metadata:
semver: "npm:^7.3.5"
styled-jsx: "npm:5.1.6"
typescript: "npm:^5.8.3"
vite-plugin-storybook-nextjs: "npm:^3.0.1"
vite-plugin-storybook-nextjs: "npm:^3.1.0"
peerDependencies:
next: ^14.1.0 || ^15.0.0 || ^16.0.0
react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
Expand Down Expand Up @@ -26439,9 +26439,9 @@ __metadata:
languageName: node
linkType: hard

"vite-plugin-storybook-nextjs@npm:^3.0.1":
version: 3.0.1
resolution: "vite-plugin-storybook-nextjs@npm:3.0.1"
"vite-plugin-storybook-nextjs@npm:^3.1.0":
version: 3.1.0
resolution: "vite-plugin-storybook-nextjs@npm:3.1.0"
dependencies:
"@next/env": "npm:16.0.0"
image-size: "npm:^2.0.0"
Expand All @@ -26453,7 +26453,7 @@ __metadata:
next: ^14.1.0 || ^15.0.0 || ^16.0.0
storybook: ^0.0.0-0 || ^9.0.0 || ^10.0.0 || ^10.0.0-0
vite: ^5.0.0 || ^6.0.0 || ^7.0.0
checksum: 10c0/f3962c8bd403afdcf8d1b1f02f32388733008e9cae35f94e1fdb47a658a4cef622e11e4f86bb66ab99a484a8ce89b519bc432782e0f965a0fd82b223354e6ac0
checksum: 10c0/a3c87a91eca84bda3b96eb8d66afa654542ed1ee3dbd3ec1a43dace4b53611e552a44d7ba8436888e965dbc6f099ddfa9c4ab91f691a19357ddc2f2cc940f9c5
languageName: node
linkType: hard

Expand Down
Loading