Hello Kitty Eyes Shut
λ³Έλ¬Έ λ°”λ‘œκ°€κΈ°

πŸ’» ν”„λ‘œμ νŠΈ/πŸ“Œ BaLaw

배럴 파일(Barrel File) 정리

λ°˜μ‘ν˜•

 

 

 

πŸŸ₯ 배럴 νŒŒμΌμ΄λž€

배럴 νŒŒμΌμ΄λž€ μ—¬λŸ¬ 개의 λͺ¨λ“ˆμ„ ν•œ 곳에 λͺ¨μ•„μ„œ λ‹€μ‹œ export ν•˜λŠ” νŒŒμΌμ„ λ§ν•œλ‹€.

즉, 각각의 λͺ¨λ“ˆμ„ κ°œλ³„μ μœΌλ‘œ import ν•˜μ§€ μ•Šκ³ ,

ν•˜λ‚˜μ˜ μ§„μž…μ (entry point)μ—μ„œ λͺ¨μ•„μ„œ 뢈러올 수 있게 ν•΄μ£ΌλŠ” 것이닀.

(보톡 파일 μ΄λ¦„μœΌλ‘œλŠ” index.ts 을 많이 μ‚¬μš©ν•œλ‹€κ³  ν•œλ‹€.)

 

 

λ‚΄ κ²½μš°μ—λŠ” μ›λž˜ μ•„λž˜μ™€ 같이 chat.ts 파일 μ•ˆμ— 말풍선과 κ΄€λ ¨λœ 토큰듀이 μ •μ˜λ˜μ–΄ μžˆμ—ˆλ‹€.

// src/styles/tokens/chat.ts

export const bubblePalette = {
  bot: { bg: 'bg-blue-50', border: 'border-blue-600', text: 'text-black' },
  me: { bg: 'bg-white', border: 'border-blue-600', text: 'text-black' },
} as const;

export const bubbleMaxW = {
  base: 'max-w-[82%]',
  sm: 'sm:max-w-[75%]',
  md: 'md:max-w-[65%]',
  lg: 'lg:max-w-[55%]',
} as const;

export const bubbleWidthClasses =
  `${bubbleMaxW.base} ${bubbleMaxW.sm} ${bubbleMaxW.md} ${bubbleMaxW.lg}` as const;

 

그리고 같은 디렉토리에 index.ts λ₯Ό λ§Œλ“€μ–΄μ„œ μ•„λž˜μ™€ 같이 배럴 νŒŒμΌμ„ μž‘μ„±ν•΄λ³΄μ•˜λ‹€.

// src/styles/tokens/index.ts

export * from './chat';

 

 

μ΄λ ‡κ²Œ ν•˜λ©΄ 이제 λ‹€λ₯Έ μ½”λ“œμ—μ„œ import ν•  λ•Œ μ•„λž˜μ™€ 같이 ν•΄μ£Όλ©΄ λœλ‹€ 😎

// Before
import { bubblePallete, bubbleMaxW } from '@/styles/tokens/chat';


// After
import { bubblePallete, bubbleMaxW } from '@/styles/tokens';

 

 


🟧 배럴 νŒŒμΌμ„ μ‚¬μš©ν•˜λŠ” 이유

배럴 νŒŒμΌμ„ μ‚¬μš©ν•˜λŠ” μ΄μœ λ‘œλŠ” 크게 4κ°€μ§€κ°€ μžˆλ‹€.

  • 가독성 ν–₯상
    • μ—¬λŸ¬ λͺ¨λ“ˆμ„ 각각 import ν•˜μ§€ μ•Šκ³ , κ³΅ν†΅λœ μ§„μž…μ  ν•˜λ‚˜λ§Œ import ν•˜λ©΄ λ˜λ‹ˆκΉŒ μ½”λ“œκ°€ 훨씬 깔끔해진닀.
  • μœ μ§€λ³΄μˆ˜ 용이
    • 파일 ꡬ쑰가 λ°”λ€Œκ±°λ‚˜ 파일λͺ…이 λ°”λ€Œμ–΄λ„ 배럴 파일만 μˆ˜μ •ν•˜λ©΄ 되고, λ‚˜λ¨Έμ§€ μ½”λ“œλ“€μ€ κ·ΈλŒ€λ‘œ μ‚¬μš© κ°€λŠ₯ν•˜λ‹€.
  • 일관성 μžˆλŠ” ꡬ쑰 제곡
  • ν™•μž₯μ„±
    • μΆ”ν›„ μƒˆλ‘œμš΄ ν† ν°μ΄λ‚˜ μœ ν‹Έλ¦¬ν‹° 파일이 μΆ”κ°€λ˜λ”λΌλ„, 배럴 νŒŒμΌμ—μ„œ ν•œ μ€„λ§Œ μΆ”κ°€ν•΄μ£Όλ©΄ λœλ‹€.

 

λ°˜μ‘ν˜•

'πŸ’» ν”„λ‘œμ νŠΈ > πŸ“Œ BaLaw' μΉ΄ν…Œκ³ λ¦¬μ˜ λ‹€λ₯Έ κΈ€

CSS λ‹¨μœ„ 정리: px, py, pt, pr, pb, pl  (0) 2025.10.07
Storybook μ„€μΉ˜ν•˜κΈ°  (0) 2025.10.01