728x90
tsconfig의 path에 아래 별칭을 이용하여 사용중이었는데
"@": ["./packages/my-app"],
"@/*": ["./packages/my-app/src/*"],
storybook내부에서 아래 별칭을 사용하려면 main.ts에 alias설정을 해줘야 한다.
https://storybook.js.org/docs/react/builders/webpack#troubleshooting
Webpack
Storybook is a frontend workshop for building UI components and pages in isolation. Thousands of teams use it for UI development, testing, and documentation. It’s open source and free.
storybook.js.org
(storybook은 webpack으로 빌드하도록 해놓았다 vite x)
/** @type { import('@storybook/react-webpack5').StorybookConfig } */
import path from 'path';
const config = {
...(생략)
webpackFinal: async (config) => {
config.resolve.alias = {
...config.resolve?.alias,
'@': path.resolve(__dirname, '../src'),
};
return config;
},
};
export default config;
위와 같은 형태로 하면 프로젝트 내에서 @/Icon 형태로 썼을 때 제대로 경로를 찾는다.
(참고용)
Resolve | 웹팩
웹팩은 모듈 번들러입니다. 주요 목적은 브라우저에서 사용할 수 있도록 JavaScript 파일을 번들로 묶는 것이지만, 리소스나 애셋을 변환하고 번들링 또는 패키징할 수도 있습니다.
webpack.kr
728x90
'Frontend > Article' 카테고리의 다른 글
rollup-plugin-postcss의 SASS 파일 내 custom alias 처리 문제 (0) | 2023.10.14 |
---|---|
Style Dictionary 사용 방법 정리(feat. 피그마 디자인 토큰 가공하기) (0) | 2023.09.23 |
자바스크립트의 숫자(Number)형 (Feat. 부동 소수점 vs 고정 소수점) (0) | 2023.05.07 |
VanillaJs로 무한 스크롤 구현하기(feat: Intersection Observer) (0) | 2023.02.12 |
[Js] 2차원 배열 new Array().fill()로 값 할당할 때 주의할 점 (0) | 2022.09.18 |