1- import { readFileSync } from 'node:fs' ;
2- import { dirname , resolve } from 'node:path' ;
3- import { fileURLToPath } from 'node:url' ;
4-
5- import type { StorybookConfig } from '@storybook/react-vite' ;
6- import { mergeAlias } from 'vite' ;
1+ import type { StorybookConfig } from "@storybook/react-vite" ;
2+ import { mergeAlias } from "vite" ;
3+ import { readFileSync } from "node:fs" ;
4+ import { dirname , resolve } from "node:path" ;
5+ import { fileURLToPath } from "node:url" ;
76
87const __filename = fileURLToPath ( import . meta. url ) ;
98const __dirname = dirname ( __filename ) ;
109
1110// react-scan is a dev-only tool — skip it in production Storybook builds.
1211// main.ts runs in Node (Storybook CLI) so we use process.env.
1312// preview.tsx runs in the browser (Vite) so it uses import.meta.env.MODE instead.
14- const isDev = process . env . NODE_ENV !== ' production' ;
13+ const isDev = process . env . NODE_ENV !== " production" ;
1514
1615// react-scan must install its devtools hook before React initializes.
1716// Two Storybook behaviors interfere with this:
@@ -22,12 +21,15 @@ const isDev = process.env.NODE_ENV !== 'production';
2221// Fix: inject a <body> script that deletes the stale property before bippy runs,
2322// forcing bippy to install a fresh hook. This all executes before React loads
2423// (React is loaded via type="module" scripts, which are deferred).
25- let reactScanHook = '' ;
24+ let reactScanHook = "" ;
2625if ( isDev ) {
2726 try {
2827 reactScanHook = readFileSync (
29- resolve ( __dirname , '../node_modules/react-scan/dist/install-hook.global.js' ) ,
30- 'utf-8'
28+ resolve (
29+ __dirname ,
30+ "../node_modules/react-scan/dist/install-hook.global.js" ,
31+ ) ,
32+ "utf-8" ,
3133 ) ;
3234 } catch {
3335 // react-scan optional; Storybook works without it
@@ -37,34 +39,34 @@ if (isDev) {
3739const config : StorybookConfig = {
3840 stories : [
3941 {
40- directory : ' ../../../packages/apollo-wind/src' ,
41- files : ' **/*.stories.@(tsx|ts|jsx|js|mdx)' ,
42- titlePrefix : ' Wind' ,
42+ directory : " ../../../packages/apollo-wind/src" ,
43+ files : " **/*.stories.@(tsx|ts|jsx|js|mdx)" ,
44+ titlePrefix : " Wind" ,
4345 } ,
4446 {
45- directory : ' ../../../packages/apollo-react/src/canvas' ,
46- files : ' **/*.stories.@(tsx|ts|jsx|js|mdx)' ,
47- titlePrefix : ' Canvas' ,
47+ directory : " ../../../packages/apollo-react/src/canvas" ,
48+ files : " **/*.stories.@(tsx|ts|jsx|js|mdx)" ,
49+ titlePrefix : " Canvas" ,
4850 } ,
4951 ] ,
5052 addons : [
51- ' @storybook/addon-links' ,
52- ' @storybook/addon-docs' ,
53- ' @storybook/addon-a11y' ,
54- ' @storybook/addon-mcp' ,
53+ " @storybook/addon-links" ,
54+ " @storybook/addon-docs" ,
55+ " @storybook/addon-a11y" ,
56+ " @storybook/addon-mcp" ,
5557 ] ,
5658 features : {
5759 experimentalComponentsManifest : true ,
5860 } ,
5961 staticDirs : [
60- ' ../../../packages/apollo-wind/public' ,
62+ " ../../../packages/apollo-wind/public" ,
6163 {
62- from : ' ../../../packages/apollo-core/src/icons/svg/third-party' ,
63- to : ' /brand' ,
64+ from : " ../../../packages/apollo-core/src/icons/svg/third-party" ,
65+ to : " /brand" ,
6466 } ,
6567 ] ,
6668 framework : {
67- name : ' @storybook/react-vite' ,
69+ name : " @storybook/react-vite" ,
6870 options : { } ,
6971 } ,
7072 previewHead : ( head ) => `
@@ -104,10 +106,16 @@ const config: StorybookConfig = {
104106 `<script>delete window.__REACT_DEVTOOLS_GLOBAL_HOOK__;${ reactScanHook } </script>\n${ body } `
105107 : undefined ,
106108 async viteFinal ( config ) {
107- const tailwindcss = ( await import ( ' @tailwindcss/vite' ) ) . default ;
109+ const tailwindcss = ( await import ( " @tailwindcss/vite" ) ) . default ;
108110
109- const apolloWindSrc = resolve ( __dirname , '../../../packages/apollo-wind/src' ) ;
110- const apolloReactSrc = resolve ( __dirname , '../../../packages/apollo-react/src' ) ;
111+ const apolloWindSrc = resolve (
112+ __dirname ,
113+ "../../../packages/apollo-wind/src" ,
114+ ) ;
115+ const apolloReactSrc = resolve (
116+ __dirname ,
117+ "../../../packages/apollo-react/src" ,
118+ ) ;
111119
112120 return {
113121 ...config ,
@@ -116,14 +124,14 @@ const config: StorybookConfig = {
116124 ...config . resolve ,
117125 alias : mergeAlias ( config . resolve ?. alias , [
118126 // ── Apollo Wind → source for HMR ──
119- { find : '@' , replacement : apolloWindSrc } ,
127+ { find : "@" , replacement : apolloWindSrc } ,
120128 {
121129 find : / ^ @ u i p a t h \/ a p o l l o - w i n d \/ t a i l w i n d \. c s s $ / ,
122- replacement : resolve ( apolloWindSrc , ' styles/tailwind.consumer.css' ) ,
130+ replacement : resolve ( apolloWindSrc , " styles/tailwind.consumer.css" ) ,
123131 } ,
124132 {
125133 find : / ^ @ u i p a t h \/ a p o l l o - w i n d $ / ,
126- replacement : resolve ( apolloWindSrc , ' index.ts' ) ,
134+ replacement : resolve ( apolloWindSrc , " index.ts" ) ,
127135 } ,
128136 {
129137 find : / ^ @ u i p a t h \/ a p o l l o - w i n d \/ (? ! .* \. c s s $ ) ( .* ) / ,
@@ -133,7 +141,7 @@ const config: StorybookConfig = {
133141 // Canvas barrel (exact match, no trailing path)
134142 {
135143 find : / ^ @ u i p a t h \/ a p o l l o - r e a c t \/ c a n v a s $ / ,
136- replacement : resolve ( apolloReactSrc , ' canvas/index.ts' ) ,
144+ replacement : resolve ( apolloReactSrc , " canvas/index.ts" ) ,
137145 } ,
138146 // Canvas subpaths (exclude xyflow CSS — vendored, only in dist)
139147 {
@@ -143,7 +151,7 @@ const config: StorybookConfig = {
143151 // Material barrel + subpaths
144152 {
145153 find : / ^ @ u i p a t h \/ a p o l l o - r e a c t \/ m a t e r i a l $ / ,
146- replacement : resolve ( apolloReactSrc , ' material/index.ts' ) ,
154+ replacement : resolve ( apolloReactSrc , " material/index.ts" ) ,
147155 } ,
148156 {
149157 find : / ^ @ u i p a t h \/ a p o l l o - r e a c t \/ m a t e r i a l \/ ( .* ) / ,
0 commit comments