From 259c48512c75ed02d73443e5a0752514d8199536 Mon Sep 17 00:00:00 2001 From: Valentin Palkovic Date: Tue, 6 Aug 2024 09:18:10 +0200 Subject: [PATCH] Support @storybook/experimental-nextjs-vite --- README.md | 4 ++-- src/plugins/next-mocks/plugin.ts | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6d7429d..b3d0b7c 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # vite-plugin-storybook-nextjs -This is a Vite plugin that allows you to use Next.js features in Vite. It is the basis for `@storybook/nextjs-vite` and should be used when running portable stories in Vitest. +This is a Vite plugin that allows you to use Next.js features in Vite. It is the basis for `@storybook/experimental-nextjs-vite` and should be used when running portable stories in Vitest. ## Features - **Next.js Integration**: Seamlessly integrate Next.js features into your Vite project. -- **Storybook Compatibility**: Acts as the foundation for `@storybook/nextjs-vite`, enabling you to use Storybook with Next.js in a Vite environment. +- **Storybook Compatibility**: Acts as the foundation for `@storybook/experimental-nextjs-vite`, enabling you to use Storybook with Next.js in a Vite environment. - **Portable Stories**: Ideal for running portable stories in Vitest, ensuring your components are tested in an environment that closely mirrors production. ## Installation diff --git a/src/plugins/next-mocks/plugin.ts b/src/plugins/next-mocks/plugin.ts index 60643cf..5076041 100644 --- a/src/plugins/next-mocks/plugin.ts +++ b/src/plugins/next-mocks/plugin.ts @@ -13,15 +13,28 @@ export const getAlias = (env: Env) => ({ "next/headers": getEntryPoint("headers", env), "@storybook/nextjs/headers.mock": getEntryPoint("headers", env), "@storybook/nextjs-vite/headers.mock": getEntryPoint("headers", env), + "@storybook/experimental-nextjs-vite/headers.mock": getEntryPoint( + "headers", + env, + ), "next/navigation": getEntryPoint("navigation", env), "@storybook/nextjs/navigation.mock": getEntryPoint("navigation", env), "@storybook/nextjs-vite/navigation.mock": getEntryPoint("navigation", env), + "@storybook/experimental-nextjs-vite/navigation.mock": getEntryPoint( + "navigation", + env, + ), "next/router": getEntryPoint("router", env), "@storybook/nextjs/router.mock": getEntryPoint("router", env), "@storybook/nextjs-vite/router.mock": getEntryPoint("router", env), + "@storybook/experimental-nextjs-vite/router.mock": getEntryPoint( + "router", + env, + ), "next/cache": getEntryPoint("cache", env), "@storybook/nextjs/cache.mock": getEntryPoint("cache", env), "@storybook/nextjs-vite/cache.mock": getEntryPoint("cache", env), + "@storybook/experimental-nextjs-vite/cache.mock": getEntryPoint("cache", env), "server-only": getEntryPoint("server-only", env), "@opentelemetry/api": require.resolve( "next/dist/compiled/@opentelemetry/api",