본문 바로가기

JavaScript/Next.js

Next.js에서 운영배포시 console 제거

1)  babel-plugin-transform-remove-console 설치

yarn add --dev babel-plugin-transform-remove-console

 

2) .babelrc 작성

{
  "presets": [
    "next/babel"
  ],
  "env": {
    "production": { // 개발시 "development"
      "plugins": [
        "transform-remove-console"
      ]
    }
  }
}

 

추가로, next.js 12.0.0 버전 이후로는 next.config.js에서 간단하게 제거할 수 있다.

https://nextjs.org/docs/advanced-features/compiler#remove-console

'JavaScript > Next.js' 카테고리의 다른 글

IE11 개발서버에서 attachShadow 이슈  (0) 2022.06.10
Next.js url 네이밍  (0) 2022.01.29
CRA와 비교한 Next.js의 장점  (0) 2021.12.08
next-redux-wrapper가 필요한 이유  (0) 2021.12.01
Data Fetching 번역  (0) 2021.11.19