Worksout 공용 이미지 유틸리티. CDN 호스트 레지스트리, URL 변환, 헤드리스 컴포넌트.
yarn add 'github:worksout/image-cdn#v0.1.0'// 1. 부팅 시 1회 — 호스트 등록 (프로젝트별 리전에 맞게)
import { registerHosts } from '@worksout/image-cdn';
registerHosts({
cdnHosts: ['media.strapi-jp.worksout-labs.com'],
s3ToCdnMap: {
'media-worksout-strapi-jp.s3.ap-northeast-1.amazonaws.com':
'media.strapi-jp.worksout-labs.com'
}
});// 2. 어디서든 동일하게
import {
getStrapiSrc,
buildStrapiSrcSet,
Picture,
fromStrapiMedia
} from '@worksout/image-cdn';
<img src={getStrapiSrc(media, 800)} />
<Picture
source={fromStrapiMedia(media)}
pcWidth={1600}
mobileWidth={828}
alt="..."
/>src/
├── core/ # React 의존 0. 순수 도메인 (HostRegistry, transform, types)
├── adapters/ # 외부 응답 → ImageSource 정규화
├── components/ # 헤드리스 React 컴포넌트 (className만 prop)
└── index.ts # 단일 진입점
yarn install
yarn build # tsup → ESM + CJS + .d.ts
yarn typecheck- PR 머지 후
package.jsonversion bump git tag vX.Y.Z && git push origin vX.Y.Z- 각 사용처에서
package.json의#vX.Y.Z갱신