You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When adding Storybook to a brand new remix run application, the following error shows up whenever attempting to run Storybook:
=> Failed to build the preview
Error: The Remix Vite plugin requires the use of a Vite config file
at configResolved (./node_modules/@remix-run/dev/dist/vite/plugin.js:744:15)
at async Promise.all (index 2)
at resolveConfig (file://./node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:66404:3)
at getOptimizeDeps (./node_modules/@storybook/builder-vite/dist/index.js:69:2932)
at createViteServer (./node_modules/@storybook/builder-vite/dist/index.js:69:3557)
at Module.start (./node_modules/@storybook/builder-vite/dist/index.js:69:4465)
at storybookDevServer (./node_modules/@storybook/core/dist/core-server/index.cjs:36000:11)
at buildOrThrow (./node_modules/@storybook/core/dist/core-server/index.cjs:35017:12)
at buildDevStandalone (./node_modules/@storybook/core/dist/core-server/index.cjs:37190:78)
at withTelemetry (./node_modules/@storybook/core/dist/core-server/index.cjs:35757:12)
WARN Broken build, fix the error above.
WARN You may need to refresh the browser
In order to resolve this problem, you have to disable the Remix plugin when Storybook is active. We achieved this using the following:
/**
* Update the Vite config to the following
* file: vite.config.ts
* /
import { vitePlugin as remix } from "@remix-run/dev";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
import type { PluginOption } from "vite";
declare module "@remix-run/node" {
interface Future {
v3_singleFetch: true;
}
}
export default defineConfig(() => {
const plugins: PluginOption[] = [tsconfigPaths()];
if (!process.env.STORYBOOK) {
plugins.push(
remix({
future: {
v3_fetcherPersist: true,
v3_relativeSplatPath: true,
v3_throwAbortReason: true,
v3_singleFetch: true,
v3_lazyRouteDiscovery: true,
},
})
);
}
return {
plugins,
};
});
/**
* set the STORYBOOK env programmatically from the storybook main
* file: .storybook/main.ts
* /
process.env.STORYBOOK = "true";
import type { StorybookConfig } from "@storybook/react-vite";
const config: StorybookConfig = {
stories: [
"../stories/**/*.mdx",
"../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)",
],
addons: [
"@storybook/addon-onboarding",
"@storybook/addon-essentials",
"@chromatic-com/storybook",
"@storybook/addon-interactions",
],
framework: {
name: "@storybook/react-vite",
options: {},
},
};
export default config;
Additional context
I am using bun as my package manager/runtime. Below is my package.json as well as the run commands for setting up a new Remix project (as referenced above) and installing storybook
Describe the problem
When adding Storybook to a brand new remix run application, the following error shows up whenever attempting to run Storybook:
In order to resolve this problem, you have to disable the Remix plugin when Storybook is active. We achieved this using the following:
Additional context
I am using
bun
as my package manager/runtime. Below is my package.json as well as the run commands for setting up a new Remix project (as referenced above) and installing storybook# set up new project bunx create-remix@latest
# install storybook bunx storybook@latest init
package.json
on the project in questionThe text was updated successfully, but these errors were encountered: