11import type { StorybookConfig } from "@storybook/react-vite" ;
2+ import { fileURLToPath , URL } from "url" ;
23
3- import { join , dirname } from "path" ;
4+ import { join , dirname , resolve } from "path" ;
45
56/**
67 * This function is used to resolve the absolute path of a package.
@@ -10,7 +11,7 @@ function getAbsolutePath(value: string) {
1011 return dirname ( require . resolve ( join ( value , "package.json" ) ) ) ;
1112}
1213const config : StorybookConfig = {
13- stories : [ "./src/stories/**/*.mdx" , "./src/**/*.stories.@(ts|tsx)" ] ,
14+ stories : [ ".. /src/stories/**/*.mdx" , ". ./src/**/*.stories.@(ts|tsx)" ] ,
1415 addons : [
1516 getAbsolutePath ( "@storybook/addon-essentials" ) ,
1617 getAbsolutePath ( "@storybook/addon-themes" ) ,
@@ -26,5 +27,17 @@ const config: StorybookConfig = {
2627 previewHead : process . env . SNAPSHOT
2728 ? ( head ) => `${ head } <style>*{animation:none!important;}</style>`
2829 : undefined ,
30+
31+ async viteFinal ( config , { configType } ) {
32+ const { mergeConfig } = await import ( 'vite' ) ;
33+
34+ return mergeConfig ( config , {
35+ resolve : {
36+ alias : {
37+ "@" : fileURLToPath ( new URL ( resolve ( __dirname , "../src/" ) , import . meta. url ) ) ,
38+ }
39+ }
40+ } )
41+ } ,
2942} ;
3043export default config ;
0 commit comments