React

Console.log

코드 작성시 console 사용에 대한 내용입니다.

해당 기능은 공통업무 기능입니다.
다음과 같이 미리 준비된 Boilerplate confy-app 형태로 제공됩니다.
빌드 시점에 특정하지 않는 console 매소드를 제거합니다.

  • develop 모드일 경우에는 console.log, console.warn, console.error, console.info, console.debug 가 정상적으로 작동합니다.
  • production 모드일 경우에는 console.debug 만 정상적으로 작동합니다.
  • console.log, console.warn, console.error, console.info, console.debug 범주 안에서 작성을 권장합니다.

Usage

설정 사항

vite.config.ts

import react from '@vitejs/plugin-react-swc'
import path from 'path'
import { defineConfig } from 'vite'
// https://vite.dev/config/
export default defineConfig(({ mode }) => ({
plugins: [react()],
resolve: {
alias: {
'@': path.resolve(__dirname, './src')
}
},
build: {
minify: 'terser',
sourcemap: true,
terserOptions:
mode === 'production'
? {
compress: {
drop_console: ['log', 'warn', 'error', 'info'],
drop_debugger: true
}
}
: undefined
}
}))

참고