-
Notifications
You must be signed in to change notification settings - Fork 1
[Init] Storybook 초기 세팅 #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
ac43172
2b19139
cd73ce8
efcb62f
75ebaae
11f6a94
029b872
5bfac51
045ecf2
32538e6
4fb2058
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,4 +24,6 @@ dist-ssr | |
| *.sln | ||
| *.sw? | ||
|
|
||
| .env | ||
| .env | ||
| *storybook.log | ||
| storybook-static | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import type { StorybookConfig } from '@storybook/react-vite'; | ||
| import { mergeConfig } from 'vite'; | ||
| import { dirname, resolve } from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
|
|
||
| const __filename = fileURLToPath(import.meta.url); | ||
| const __dirname = dirname(__filename); | ||
|
|
||
| const config: StorybookConfig = { | ||
| stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'], | ||
|
|
||
| addons: [ | ||
| '@storybook/addon-docs', | ||
| '@storybook/addon-a11y', | ||
| ], | ||
|
|
||
| framework: '@storybook/react-vite', | ||
|
|
||
| viteFinal: async (storybookConfig) => | ||
| mergeConfig(storybookConfig, { | ||
| resolve: { | ||
| alias: { | ||
| '@': resolve(__dirname, '../src'), | ||
| '@app': resolve(__dirname, '../src/app'), | ||
| '@pages': resolve(__dirname, '../src/pages'), | ||
| '@widgets': resolve(__dirname, '../src/widgets'), | ||
| '@features': resolve(__dirname, '../src/features'), | ||
| '@shared': resolve(__dirname, '../src/shared'), | ||
| '@images': resolve(__dirname, '../src/shared/assets/images'), | ||
| '@icons': resolve(__dirname, '../src/shared/assets/icons'), | ||
| '@api': resolve(__dirname, '../src/shared/api'), | ||
| '@config': resolve(__dirname, '../src/shared/config'), | ||
| '@model': resolve(__dirname, '../src/shared/model'), | ||
| '@styles': resolve(__dirname, '../src/shared/styles'), | ||
| '@types': resolve(__dirname, '../src/shared/types'), | ||
| '@ui': resolve(__dirname, '../src/shared/ui'), | ||
| '@lib': resolve(__dirname, '../src/shared/lib'), | ||
| }, | ||
| }, | ||
| }), | ||
|
|
||
| typescript: { | ||
| reactDocgen: 'react-docgen-typescript', | ||
| reactDocgenTypescriptOptions: { | ||
| shouldExtractLiteralValuesFromEnum: true, | ||
| propFilter: (prop) => !/node_modules/.test(prop.parent?.fileName || ''), | ||
| }, | ||
|
Comment on lines
19
to
23
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 옵셔널 타입의 경우(ex. disabled?: boolean), storybook상에 생성될 문서에 boolean(true, false) 뿐만 아니라 undefined까지 함께 보여진다고 해요. |
||
| }, | ||
| }; | ||
|
|
||
| export default config; | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,22 @@ | ||||||||||||||||||||||||||||
| import type { Preview } from '@storybook/react-vite'; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| // 나중에 전역 스타일 여기서 import | ||||||||||||||||||||||||||||
| // vanilla-extract의 globalStyle / theme entry 여기서 불러옴 | ||||||||||||||||||||||||||||
| // 예: import '@/shared/styles/global.css.ts'; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const preview: Preview = { | ||||||||||||||||||||||||||||
| parameters: { | ||||||||||||||||||||||||||||
| layout: 'padded', | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| actions: { argTypesRegex: '^on[A-Z].*' }, | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| controls: { | ||||||||||||||||||||||||||||
| matchers: { | ||||||||||||||||||||||||||||
| color: /(background|color)$/i, | ||||||||||||||||||||||||||||
| date: /Date$/i, | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
|
Comment on lines
+13
to
+18
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 스토리북의 대부분 컴포넌트에서 docs 파일이 생성될 거라면,
Suggested change
|
||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| export default preview; | ||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
스토리북 파일 내부에서도 path alias형태로 가져올 수 있게 정의해준 점 너무 좋은 것 같아요!
vite.config.ts,tsconfig.app.json에서 새로운 path가 추가될 때마다 스토리북 내부에서도 이를 같이 동기화시킬 필요가 있을 것 같아서vite-tsconfig-paths플러그인으로 싱크 맞춰주는 방법도 한 번 제안드려봐요 🎵