728x90
next.js 13버전 때 학습내용 정리 문서로 현재와 다름 주의
Absolute Imports and Module Path Aliases
절대경로 import
// tsconfig.json
{
"compilerOptions": {
"baseUrl": "."
}
}
import Button from 'components/button';
export default function HomePage() {
return (
<>
<h1>Hello World</h1>
<Button />
</>
);
}
별칭 import
// tsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/components/*": ["components/*"]
}
}
}
import Button from '@/components/button';
export default function HomePage() {
return (
<>
<h1>Hello World</h1>
<Button />
</>
);
}
'공부공부 > Next.js 공식문서' 카테고리의 다른 글
[next.js 공식문서] 27. Environment Variables (0) | 2024.03.07 |
---|---|
[next.js 공식문서] 26. ESLint (0) | 2024.03.07 |
[next.js 공식문서] 25. TypeScript (0) | 2024.03.07 |
[next.js 공식문서] 24. Instrumentation (0) | 2024.03.05 |
[next.js 공식문서] 23. OpenTelemetry (0) | 2024.03.05 |