Front-end/Next.js
[Next.js] Metadata, env, removeConsole, TurboPack
Bay Im
2024. 3. 8. 00:29
- dynamic metadata
- 예시
-
export async function generateMetadata({ params: { todoId } }: Params): Promise<Metadata> { const todo: Todo = await getTodo(todoId); return { title: todo.title, }; }
- .env 지원
- default support dotenv
- .env.local (또는 .env.development.local)
- .env.development
- .env
- next.config.js
- process.env.customKey 로 사용 가능
module.exports = { env: { customKey: 'my-value', }, }
- 민감한 정보는 키 값 그대로 commit & push 하지 말 것
- default support dotenv
- remove console
- next.config.js 생성
- 형식
- removeConsole: true | {exclude: […]}
- 예시
const nextConfig = { compiler: { removeConsole: { exclude: ['error', 'debug'], }, }, };
- 형식
- build시 소스 코드의 console.log 자동 제거 해준다.
- next.config.js 생성
- Using TurboPack 사용
- package.json 수정
-
"scripts": { "dev": "next dev --port 3001", "dev:turbo": "next dev --turbo", "build": "next build", }
728x90