-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathtsup.config.ts
More file actions
63 lines (50 loc) · 1.9 KB
/
tsup.config.ts
File metadata and controls
63 lines (50 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import {defineConfig} from 'tsup';
// NODE_ENV 값에 따라 개발(build --watch) / 프로덕션(build) 옵션을 자동 전환합니다.
export default defineConfig(({watch}) => {
const isProd = !watch; // watch 모드가 아니면 프로덕션 빌드로 간주
const enableDebug = process.env.DEBUG === 'true';
return {
// 엔트리 포인트
entry: ['src/index.ts'],
// 출력 위치를 package.json 의 파일 경로와 동일하게 맞춥니다.
outDir: 'dist',
// 모듈 포맷: CJS + ESM 동시 지원
format: ['cjs', 'esm'],
// Node 18 LTS 타겟
target: 'node18',
platform: 'node',
// 타입 선언 파일(.d.ts) 생성
dts: true,
// 디버그 모드에서는 minify 비활성화
minify: isProd && !enableDebug,
treeshake: isProd && !enableDebug,
// 디버그 모드이거나 개발 환경에서는 소스맵 생성
sourcemap: !isProd || enableDebug,
// 빌드 전 dist 폴더 정리
clean: true,
// ESM 포맷에서 코드 분할을 비활성화하여 단일 파일 생성 (라이브러리 배포에 유리)
splitting: false,
// 환경 변수 정의 - 에러 포맷팅을 위해 중요
define: {
'process.env.NODE_ENV': isProd ? '"production"' : '"development"',
'process.env.EFFECT_DEBUG': enableDebug ? '"true"' : '"false"',
},
// 경로 별칭 설정 – 특정 디렉토리용 별칭 정의
alias: {
'@models': './src/models',
'@lib': './src/lib',
'@internal-types': './src/types',
'@services': './src/services',
'@errors': './src/errors',
// 루트 src 하위 전체를 가리키는 옵션을 추가적으로 원한다면 아래 라인을 유지하세요.
'@': './src',
},
// tsup --watch 시 변경 감지를 무시할 경로
ignoreWatch: [
'**/debug/**',
'**/changelog/**',
'**/examples/**',
'**/docs/**',
],
};
});