next.js 에서 dotenv 사용

2ERO·2022년 10월 6일
0

dotenv-webpack 라이브러리를 설치한다

yarn add dotenv-webpack

설치 후 next.config.js 에서 dotenv 플러그인을 연결해준다.

기존 next.config.js 파일
const Dotenv = require('dotenv-webpack')

const nextConfig = {
.... blah
webpack: (config) => {
config.plugins.push(new Dotenv({silent: true}))
return config
}
}

module.exports = nextConfig

profile
이것저것 간단하게 적어놓는 블로그

0개의 댓글